Class: Defaultable::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/defaultable/registry.rb

Instance Method Summary collapse

Constructor Details

#initializeRegistry

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_hashObject



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