Class: Wardrobe::Store
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/wardrobe/store.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
8
9
10
11
|
# File 'lib/wardrobe/store.rb', line 8
def initialize
@store = {}
freeze
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **key_args, &block) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/wardrobe/store.rb', line 30
def method_missing(name, *args, **key_args, &block)
if (atr = store[name])
atr
else
super
end
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
6
7
8
|
# File 'lib/wardrobe/store.rb', line 6
def parent
@parent
end
|
#store ⇒ Object
Returns the value of attribute store.
6
7
8
|
# File 'lib/wardrobe/store.rb', line 6
def store
@store
end
|
Instance Method Details
#[](name) ⇒ Object
17
18
19
|
# File 'lib/wardrobe/store.rb', line 17
def [](name)
store[name]
end
|
#del(name) ⇒ Object
46
47
48
49
50
|
# File 'lib/wardrobe/store.rb', line 46
def del(name)
mutate do
store.delete(name) { |key| raise "#{key} not found" }
end
end
|
#each(&blk) ⇒ Object
21
22
23
|
# File 'lib/wardrobe/store.rb', line 21
def each(&blk)
store.each(&blk)
end
|
#freeze ⇒ Object
25
26
27
28
|
# File 'lib/wardrobe/store.rb', line 25
def freeze
store.freeze
super
end
|
#merge(other, _calling_object, _config) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/wardrobe/store.rb', line 38
def merge(other, _calling_object, _config)
mutate do
@store = store.merge(other.store)
end
end
|
#values ⇒ Object
13
14
15
|
# File 'lib/wardrobe/store.rb', line 13
def values
store.values
end
|