Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/orogen/base.rb

Instance Method Summary collapse

Instance Method Details

#enumerate_inherited_map(each_name, attribute_name = each_name) ⇒ Object

:nodoc:


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/orogen/base.rb', line 35

def enumerate_inherited_map(each_name, attribute_name = each_name) # :nodoc:
    class_eval "attr_reader :\#{attribute_name}\ndef all_\#{attribute_name}; each_\#{each_name}.to_a end\ndef self_\#{attribute_name}; @\#{attribute_name}.values end\ndef has_\#{attribute_name}?(name); !!find_\#{each_name}(name) end\n\ndef find_\#{each_name}(name)\nname = name.to_str\nif v = @\#{attribute_name}[name]\nv\nelsif superclass\nsuperclass.find_\#{each_name}(name)\nend\nend\ndef each_\#{each_name}(&block)\nif block_given?\nif superclass\nsuperclass.each_\#{each_name}(&block)\nend\[email protected]\#{attribute_name}.each_value(&block)\nelse\nenum_for(:each_\#{each_name})\nend\nend\n", __FILE__, __LINE__
end

#enumerate_inherited_set(each_name, attribute_name = each_name) ⇒ Object

:nodoc:


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

def enumerate_inherited_set(each_name, attribute_name = each_name) # :nodoc:
    class_eval "def find_\#{attribute_name}(name)\neach_\#{each_name} do |n|\nreturn n if n.name == name\nend\nend\ndef all_\#{attribute_name}; each_\#{each_name}.to_a end\ndef self_\#{attribute_name}; @\#{attribute_name} end\ndef each_\#{each_name}(&block)\nif block_given?\nif superclass\nsuperclass.each_\#{each_name}(&block)\nend\[email protected]\#{attribute_name}.each(&block)\nelse\nenum_for(:each_\#{each_name})\nend\nend\n", __FILE__, __LINE__
end