/
property_container.rb
50 lines (43 loc) · 1.19 KB
/
property_container.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#coding: utf-8
module Wombat
module DSL
class PropertyContainer < Hash
attr_accessor :name
def initialize(name = nil)
@name = name
end
def method_missing(method, *args, &block)
property_name = method.to_s
if args.empty? && block
self[property_name] = PropertyContainer.new(property_name) unless self[property_name]
block.call self[property_name]
else
unless args[1] == :iterator
self[property_name] = Property.new(
name: property_name,
selector: args.first,
format: args[1],
namespaces: args[2],
callback: block)
else
it = Iterator.new(property_name, args.first)
self[property_name] = it
it.instance_eval(&block) if block
end
end
end
def to_ary
end
# So that Property::Locators::Iterator can identify this class
# as an iterator property.
# TODO: Called by NodeSelector. Fix this
def format
:container
end
def namespaces
# TODO: Called by NodeSelector. Fix this
nil
end
end
end
end