Sha256: 40077e456353c6453fcb3c1daaedde2a4d293c609310e371e0a97fdf52f868a5

Contents?: true

Size: 589 Bytes

Versions: 4

Compression:

Stored size: 589 Bytes

Contents

# RGen Framework
# (c) Martin Thiede, 2006

require 'rgen/metamodel_builder'

class Array

	def >>(method)
		compact.inject([]) { |r,e| r | ( (o=e.send(method)).is_a?(Array) ? o : [o] ) }
	end
	
	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

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rgen-0.2.0 lib/rgen/array_extensions.rb
rgen-0.4.0 lib/rgen/array_extensions.rb
rgen-0.3.0 lib/rgen/array_extensions.rb
rgen-0.4.1 lib/rgen/array_extensions.rb