Class: Cogwheels::Configuration
- Inherits:
-
Object
- Object
- Cogwheels::Configuration
- Defined in:
- lib/cogwheels/configuration.rb
Overview
This class contains configuration information loaded from YAML sources
Defined Under Namespace
Classes: ImmutableConfigurationError
Instance Attribute Summary collapse
-
#mutable ⇒ Object
readonly
Returns the value of attribute mutable.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(hash, mutable = true) ⇒ Configuration
constructor
A new instance of Configuration.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hash, mutable = true) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 |
# File 'lib/cogwheels/configuration.rb', line 9 def initialize(hash, mutable = true) @hash = hash @mutable = mutable end |
Instance Attribute Details
#mutable ⇒ Object (readonly)
Returns the value of attribute mutable.
7 8 9 |
# File 'lib/cogwheels/configuration.rb', line 7 def mutable @mutable end |
Instance Method Details
#[](key) ⇒ Object
14 15 16 |
# File 'lib/cogwheels/configuration.rb', line 14 def [](key) @hash[key] end |
#[]=(key, value) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/cogwheels/configuration.rb', line 18 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 ⇒ Object
32 33 34 |
# File 'lib/cogwheels/configuration.rb', line 32 def inspect "Cogwheels::Configuration =>\n#{@hash}" end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/cogwheels/configuration.rb', line 28 def to_s @hash.to_s end |