Class: Lipa::Bunch

Inherits:
Object
  • Object
show all
Defined in:
lib/lipa/bunch.rb

Overview

Implementation of group description

Examples:

tree = root :tree do 
  bunch :param_1 => "some_param" do
    leaf :obj_1
    leaf :obj_2
  end
end

tree["obj_1"].param_1 #=> "some_param"
tree["obj_2"].param_1 #=> "some_param"

Instance Method Summary collapse

Constructor Details

#initialize(parent, attrs = {}, &block) ⇒ Bunch

Returns a new instance of Bunch.



40
41
42
43
44
45
# File 'lib/lipa/bunch.rb', line 40

def initialize(parent, attrs = {}, &block)
  @attrs = attrs
  @parent = parent

  instance_eval &block if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



47
48
49
50
51
52
# File 'lib/lipa/bunch.rb', line 47

def method_missing(name, *args, &block)
  args[1] = @attrs.merge(args[1] || {})
  unless Node.add_node(name, @parent, *args, &block)
    super
  end
end