Class: ActiveRecord::Turntable::Configuration::Loader::YAML

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/turntable/configuration/loader/yaml.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, configuration = Configuration.new) ⇒ YAML

Returns a new instance of YAML.



6
7
8
9
10
# File 'lib/active_record/turntable/configuration/loader/yaml.rb', line 6

def initialize(path, configuration = Configuration.new)
  @path = path
  @configuration = configuration
  @dsl = DSL.new(@configuration)
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



4
5
6
# File 'lib/active_record/turntable/configuration/loader/yaml.rb', line 4

def configuration
  @configuration
end

#dslObject (readonly)

Returns the value of attribute dsl.



4
5
6
# File 'lib/active_record/turntable/configuration/loader/yaml.rb', line 4

def dsl
  @dsl
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/active_record/turntable/configuration/loader/yaml.rb', line 4

def path
  @path
end

Class Method Details

.load(path, env, configuration = Configuration.new) ⇒ Object



12
13
14
# File 'lib/active_record/turntable/configuration/loader/yaml.rb', line 12

def self.load(path, env, configuration = Configuration.new)
  new(path, configuration).load(env)
end

Instance Method Details

#load(env) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/active_record/turntable/configuration/loader/yaml.rb', line 16

def load(env)
  yaml = YAML.load(ERB.new(IO.read(path)).result).with_indifferent_access[env]
  load_clusters(yaml[:clusters])
  load_global_settings(yaml)

  configuration
end