Class: ActiveRecord::Turntable::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/active_record/turntable/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](key) ⇒ Object



8
9
10
# File 'lib/active_record/turntable/config.rb', line 8

def self.[](key)
  instance[key]
end

.load!(config_file = ActiveRecord::Base.turntable_config_file, env = (Rails) ? Rails.env : 'development')) ⇒ Object



17
18
19
# File 'lib/active_record/turntable/config.rb', line 17

def self.load!(config_file = ActiveRecord::Base.turntable_config_file, env = (defined?(Rails) ? Rails.env : 'development'))
  instance.load!(config_file, env)
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
15
# File 'lib/active_record/turntable/config.rb', line 12

def [](key)
  self.class.load!(ActiveRecord::Base.turntable_config_file) unless @config
  @config[key]
end

#load!(config_file, env) ⇒ Object



21
22
23
24
# File 'lib/active_record/turntable/config.rb', line 21

def load!(config_file, env)
  @config = YAML.load(ERB.new(IO.read(config_file)).result).with_indifferent_access[env]
  ActiveSupport.run_load_hooks(:turntable_config_loaded, ActiveRecord::Base)
end