Skip to content

Commit

Permalink
Adding renamed classes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecsl committed Jul 31, 2012
1 parent 590c352 commit a602a58
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
50 changes: 50 additions & 0 deletions lib/wombat/dsl/property_group.rb
@@ -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
20 changes: 20 additions & 0 deletions lib/wombat/property/locators/property_group.rb
@@ -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

0 comments on commit a602a58

Please sign in to comment.