Skip to content

Commit 6c6ccda

Browse files
authored
Remove Code Duplication (#732)
## What this does cf61b71 introduced the save_to_database method, but did not replace the (identical) partial implementation in the existing refresh! method. ## Type of change - [ ] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Documentation - [ ] Performance improvement - [x] Code maintainability ## Scope check - [x] I read the [Contributing Guide](https://github.com/crmne/ruby_llm/blob/main/CONTRIBUTING.md) - [x] This aligns with RubyLLM's focus on **LLM communication** - [x] This isn't application-specific logic that belongs in user code - [x] This benefits most users, not just my specific use case ## Quality check - [x] I ran `overcommit --install` and all hooks pass - [x] I tested my changes thoroughly - [ ] For provider changes: Re-recorded VCR cassettes with `bundle exec rake vcr:record[provider_name]` - [x] All tests pass: `bundle exec rspec` - [ ] I updated documentation if needed - [ ] I didn't modify auto-generated files manually (`models.json`, `aliases.json`) ## AI-generated code - [ ] I used AI tools to help write this code - [ ] I have reviewed and understand all generated code (required if above is checked) ## API changes - [ ] Breaking change - [ ] New public methods/classes - [ ] Changed method signatures - [x] No API changes
1 parent 9f82751 commit 6c6ccda

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

lib/ruby_llm/active_record/model_methods.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@ module ModelMethods
1010
def refresh!
1111
RubyLLM.models.refresh!
1212

13-
transaction do
14-
RubyLLM.models.all.each do |model_info|
15-
model = find_or_initialize_by(
16-
model_id: model_info.id,
17-
provider: model_info.provider
18-
)
19-
model.update!(from_llm_attributes(model_info))
20-
end
21-
end
13+
save_to_database
2214
end
2315

2416
def save_to_database

0 commit comments

Comments
 (0)