Class: Wombat::DSL::PropertyGroup

Inherits:
Hash
  • Object
show all
Defined in:
lib/wombat/dsl/property_group.rb

Direct Known Subclasses

Follower, Iterator, Metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ PropertyGroup

Returns a new instance of PropertyGroup.



8
9
10
# File 'lib/wombat/dsl/property_group.rb', line 8

def initialize(name = nil)
  @wombat_property_name = name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/wombat/dsl/property_group.rb', line 12

def method_missing(method, *args, &block)
  property_name = method.to_s

  if args.empty? && block
    # TODO: Verify if another property with same name already exists
    # before overwriting
    property_group = self[property_name] || PropertyGroup.new(property_name)
    self[property_name] = property_group
    property_group.instance_eval(&block)
  else
    if args[1] == :iterator
      it = Iterator.new(property_name, args.first)
      self[property_name] = it
      it.instance_eval(&block) if block
    elsif args[1] == :follow
      it = Follower.new(property_name, args.first)
      self[property_name] = it
      it.instance_eval(&block) if block
    else
      self[property_name] = Property.new(property_name, *args, &block)
    end
  end      
end

Instance Attribute Details

#wombat_property_nameObject

Returns the value of attribute wombat_property_name.



6
7
8
# File 'lib/wombat/dsl/property_group.rb', line 6

def wombat_property_name
  @wombat_property_name
end

Instance Method Details

#to_aryObject



36
37
# File 'lib/wombat/dsl/property_group.rb', line 36

def to_ary
end

#wombat_property_formatObject



39
40
41
# File 'lib/wombat/dsl/property_group.rb', line 39

def wombat_property_format
  :container
end

#wombat_property_namespacesObject



43
44
45
# File 'lib/wombat/dsl/property_group.rb', line 43

def wombat_property_namespaces
  nil
end