class Cogwheels::Configuration
This class contains configuration information loaded from YAML sources
Attributes
hash[R]
mutable[R]
Public Class Methods
new(hash, mutable = true)
click to toggle source
# File lib/cogwheels/configuration.rb, line 9 def initialize(hash, mutable = true) @hash = {} hash.each do |key, value| if value.is_a?(Hash) value_config = Configuration.new(value, mutable) @hash[key] = value_config else @hash[key] = value end end @mutable = mutable end
Public Instance Methods
==(other)
click to toggle source
# File lib/cogwheels/configuration.rb, line 68 def ==(other) hash == other.hash && mutable == other.mutable end
[](key, default = nil)
click to toggle source
# File lib/cogwheels/configuration.rb, line 22 def [](key, default = nil) @hash[key] ||= default end
[]=(key, value)
click to toggle source
# File lib/cogwheels/configuration.rb, line 26 def []=(key, value) unless @mutable error = <<-EOF A modification was attempted on an immutable Configuration instance. EOF raise ImmutableConfigurationError, error end @hash[key] = value if @mutable end
inspect()
click to toggle source
# File lib/cogwheels/configuration.rb, line 64 def inspect "Cogwheels::Configuration (mutable: #{mutable}) =>\n#{@hash}" end
key?(key)
click to toggle source
# File lib/cogwheels/configuration.rb, line 36 def key?(key) @hash.key?(key) end
keys()
click to toggle source
# File lib/cogwheels/configuration.rb, line 40 def keys @hash.keys end
to_s()
click to toggle source
# File lib/cogwheels/configuration.rb, line 60 def to_s @hash.to_s end
to_symbol_keys()
click to toggle source
# File lib/cogwheels/configuration.rb, line 46 def to_symbol_keys @new_hash = {} @hash.each do |key, value| key = key.to_sym @new_hash[key] = if value.is_a?(Cogwheels::Configuration) value.to_symbol_keys else value end end @hash = @new_hash self end