Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#coding: utf-8 | ||
|
||
module Wombat | ||
module DSL | ||
class PropertyGroup < Hash | ||
attr_accessor :wombat_property_name | ||
|
||
def initialize(name = nil) | ||
@wombat_property_name = name | ||
end | ||
|
||
def method_missing(method, *args, &block) | ||
property_name = method.to_s | ||
|
||
if args.empty? && block | ||
self[property_name] = PropertyGroup.new(property_name) unless self[property_name] | ||
block.call self[property_name] | ||
else | ||
unless args[1] == :iterator | ||
self[property_name] = Property.new( | ||
wombat_property_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#coding: utf-8 | ||
|
||
module Wombat | ||
module Property | ||
module Locators | ||
class PropertyGroup < Base | ||
def locate | ||
super do | ||
Hash.new.tap do |h| | ||
@property.values | ||
.select { |v| v.is_a?(Wombat::DSL::Property) || v.is_a?(Wombat::DSL::PropertyGroup) } | ||
.map { |p| Factory.locator_for(p, @context).locate } | ||
.map { |p| h.merge! p } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |