|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -module RubyLLM |
4 | | - # Rails integration for RubyLLM |
5 | | - class Railtie < Rails::Railtie |
6 | | - initializer 'ruby_llm.inflections' do |
7 | | - ActiveSupport::Inflector.inflections(:en) do |inflect| |
8 | | - inflect.acronym 'RubyLLM' |
| 3 | +if defined?(Rails::Railtie) |
| 4 | + module RubyLLM |
| 5 | + # Rails integration for RubyLLM |
| 6 | + class Railtie < Rails::Railtie |
| 7 | + initializer 'ruby_llm.inflections' do |
| 8 | + ActiveSupport::Inflector.inflections(:en) do |inflect| |
| 9 | + inflect.acronym 'RubyLLM' |
| 10 | + end |
9 | 11 | end |
10 | | - end |
11 | 12 |
|
12 | | - initializer 'ruby_llm.active_record' do |
13 | | - ActiveSupport.on_load :active_record do |
14 | | - if RubyLLM.config.use_new_acts_as |
15 | | - require 'ruby_llm/active_record/acts_as' |
16 | | - ::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAs |
17 | | - else |
18 | | - require 'ruby_llm/active_record/acts_as_legacy' |
19 | | - ::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAsLegacy |
| 13 | + initializer 'ruby_llm.active_record' do |
| 14 | + ActiveSupport.on_load :active_record do |
| 15 | + if RubyLLM.config.use_new_acts_as |
| 16 | + require 'ruby_llm/active_record/acts_as' |
| 17 | + ::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAs |
| 18 | + else |
| 19 | + require 'ruby_llm/active_record/acts_as_legacy' |
| 20 | + ::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAsLegacy |
20 | 21 |
|
21 | | - Rails.logger.warn( |
22 | | - "\n!!! RubyLLM's legacy acts_as API is deprecated and will be removed in RubyLLM 2.0.0. " \ |
23 | | - "Please consult the migration guide at https://rubyllm.com/upgrading-to-1-7/\n" |
24 | | - ) |
| 22 | + Rails.logger.warn( |
| 23 | + "\n!!! RubyLLM's legacy acts_as API is deprecated and will be removed in RubyLLM 2.0.0. " \ |
| 24 | + "Please consult the migration guide at https://rubyllm.com/upgrading-to-1-7/\n" |
| 25 | + ) |
| 26 | + end |
25 | 27 | end |
26 | 28 | end |
27 | | - end |
28 | 29 |
|
29 | | - rake_tasks do |
30 | | - load 'tasks/ruby_llm.rake' |
| 30 | + rake_tasks do |
| 31 | + load 'tasks/ruby_llm.rake' |
| 32 | + end |
31 | 33 | end |
32 | 34 | end |
33 | 35 | end |
0 commit comments