Module: RemoteDb::Concerns::Configurable::ClassMethods
- Defined in:
- lib/remote_db/concerns/configurable.rb
Instance Method Summary collapse
- #configuration ⇒ Object
- #configure(config_hash = nil) {|configuration| ... } ⇒ Object
- #load_models!(options = { readonly: true }) ⇒ Object
- #without_readonly ⇒ Object
Instance Method Details
#configuration ⇒ Object
22 23 24 |
# File 'lib/remote_db/concerns/configurable.rb', line 22 def configuration @configuration ||= RemoteDb::Configuration.new end |
#configure(config_hash = nil) {|configuration| ... } ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/remote_db/concerns/configurable.rb', line 9 def configure(config_hash = nil) if config_hash config_hash.each do |k,v| setter = "#{k}=" if configuration.respond_to?(setter ) configuration.send(setter , v) end end end yield(configuration) if block_given? end |
#load_models!(options = { readonly: true }) ⇒ Object
34 35 36 37 38 |
# File 'lib/remote_db/concerns/configurable.rb', line 34 def load_models!( = { readonly: true }) clear_old_models define_base_record() send(:require_models) if respond_to?(:require_models) end |
#without_readonly ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/remote_db/concerns/configurable.rb', line 26 def without_readonly raise ForbiddenActionException unless configuration.environment == :test load_models!(readonly: false) yield load_models!(readonly: true) end |