Class: Yarrow::ContentMap
- Inherits:
-
Object
- Object
- Yarrow::ContentMap
show all
- Defined in:
- lib/yarrow/content_map.rb
Constant Summary
collapse
- @@registry =
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ContentMap.
24
25
26
|
# File 'lib/yarrow/content_map.rb', line 24
def initialize
@objects = Hashie::Mash.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
28
29
30
|
# File 'lib/yarrow/content_map.rb', line 28
def method_missing(method, *args, &block)
@objects[method] = block ? ContentMap.build(&block) : args.first
end
|
Instance Attribute Details
#objects ⇒ Object
Returns the value of attribute objects.
22
23
24
|
# File 'lib/yarrow/content_map.rb', line 22
def objects
@objects
end
|
Class Method Details
.[](name) ⇒ Object
6
7
8
|
# File 'lib/yarrow/content_map.rb', line 6
def self.[](name)
@@registry[name]
end
|
.build(&block) ⇒ Object
16
17
18
19
20
|
# File 'lib/yarrow/content_map.rb', line 16
def self.build(&block)
content_map = ContentMap.new
content_map.instance_eval(&block)
content_map.objects
end
|
.define(name, &block) ⇒ Object
10
11
12
13
14
|
# File 'lib/yarrow/content_map.rb', line 10
def self.define(name, &block)
content_map = ContentMap.new
content_map.instance_eval(&block)
@@registry[name] = content_map.objects
end
|