Class: Defaultable::Registry
- Inherits:
-
Object
- Object
- Defaultable::Registry
- Defined in:
- lib/defaultable/registry.rb
Instance Method Summary collapse
- #add(key, value) ⇒ Object
- #as_hash ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
5 6 7 |
# File 'lib/defaultable/registry.rb', line 5 def initialize @table = HashWithIndifferentAccess.new end |
Instance Method Details
#add(key, value) ⇒ Object
9 10 11 |
# File 'lib/defaultable/registry.rb', line 9 def add(key, value) @table[key] = value end |
#as_hash ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/defaultable/registry.rb', line 13 def as_hash @table.inject({}) do |hash, (key, val)| if val.kind_of?(Defaultable::Settings) val = val.registry.as_hash else val end hash[key] = val hash end end |