Class: Array
- Inherits:
-
Object
show all
- Defined in:
- lib/rgen/array_extensions.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/rgen/array_extensions.rb', line 12
def method_missing(m, *args)
super unless size == 0 or compact.any?{|e| e.is_a? RGen::MetamodelBuilder::MMBase}
compact.inject([]) { |r,e|
if e.is_a? RGen::MetamodelBuilder::MMBase
r | ( (o=e.send(m)).is_a?(Array) ? o : [o] )
else
raise StandardError.new("Trying to call a method on an array element not a RGen MMBase")
end
}.compact
end
|
Instance Method Details
#>>(method) ⇒ Object
8
9
10
|
# File 'lib/rgen/array_extensions.rb', line 8
def >>(method)
compact.inject([]) { |r,e| r | ( (o=e.send(method)).is_a?(Array) ? o : [o] ) }
end
|