class Roxanne::Configuration::YAML
Public Class Methods
new(path)
click to toggle source
Calls superclass method
Roxanne::Configuration::Base::new
# File lib/roxanne/configuration/yaml.rb, line 10 def initialize(path) super yaml = ::YAML.load( File.open( path ) ).with_indifferent_access[:roxanne] override_activation(yaml[:activation]) build_consumers(yaml[:consumers]) build_publisher(yaml[:publisher]) end
Private Instance Methods
assign_properties(object, hash)
click to toggle source
# File lib/roxanne/configuration/yaml.rb, line 36 def assign_properties(object, hash) hash.each do |prop, value| object.send "#{prop}=", value end object end
build_consumers(hash)
click to toggle source
# File lib/roxanne/configuration/yaml.rb, line 26 def build_consumers(hash) (hash||{}).each do |id, hash| @consumers << assign_properties( hash.delete(:class).constantize.new, hash ) end end
build_publisher(hash)
click to toggle source
# File lib/roxanne/configuration/yaml.rb, line 32 def build_publisher(hash) @publisher = assign_properties( hash.delete(:class).constantize.new, hash) end
override_activation(settings)
click to toggle source
# File lib/roxanne/configuration/yaml.rb, line 19 def override_activation(settings) if settings @active_days = settings[:days] if settings.has_key?(:days) @timerange = settings[:timerange] if settings.has_key?(:timerange) end end