Class: SequelRails::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- SequelRails::Railtie
- Defined in:
- lib/sequel_rails/railtie.rb
Instance Method Summary collapse
- #check_skip_connect_conditions(app) ⇒ Object
-
#configure_sequel(app) ⇒ Object
Support overwriting crucial steps in subclasses.
- #database_connection_required?(app) ⇒ Boolean
- #setup_controller_runtime ⇒ Object
- #setup_i18n_support ⇒ Object
- #skip_db_connect? ⇒ Boolean
Instance Method Details
#check_skip_connect_conditions(app) ⇒ Object
110 111 112 |
# File 'lib/sequel_rails/railtie.rb', line 110 def check_skip_connect_conditions(app) app.config.sequel[:skip_connect] ||= skip_db_connect? end |
#configure_sequel(app) ⇒ Object
Support overwriting crucial steps in subclasses
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/sequel_rails/railtie.rb', line 82 def configure_sequel(app) rails_db_config = begin app.config.database_configuration rescue RuntimeError => e raise unless e. =~ /Cannot load database configuration/ {} # will try to use DATABASE_URL rescue Errno::ENOENT {} # will try to use DATABASE_URL end app.config.sequel.merge!( :root => ::Rails.root, :raw => rails_db_config ) ::SequelRails.configuration = app.config.sequel end |
#database_connection_required?(app) ⇒ Boolean
114 115 116 |
# File 'lib/sequel_rails/railtie.rb', line 114 def database_connection_required?(app) !app.config.sequel[:skip_connect] end |
#setup_controller_runtime ⇒ Object
105 106 107 108 |
# File 'lib/sequel_rails/railtie.rb', line 105 def setup_controller_runtime require 'sequel_rails/railties/controller_runtime' ActionController::Base.send :include, SequelRails::Railties::ControllerRuntime end |
#setup_i18n_support ⇒ Object
100 101 102 103 |
# File 'lib/sequel_rails/railtie.rb', line 100 def setup_i18n_support ::Sequel::Model.send :extend, ::ActiveModel::Translation ::Sequel::Model.send :extend, ::SequelRails::I18nSupport end |
#skip_db_connect? ⇒ Boolean
118 119 120 121 122 |
# File 'lib/sequel_rails/railtie.rb', line 118 def skip_db_connect? Rake.application.top_level_tasks.any? do |task| task.match?(/^db:create|db:test:prepare|^db:drop|db:setup/) end end |