Module: Momo

Defined in:
lib/momo.rb,
lib/momo/cfl.rb,
lib/momo/stack.rb,
lib/momo/mapping.rb,
lib/momo/version.rb,
lib/momo/funccall.rb,
lib/momo/resource.rb,
lib/momo/momoscope.rb,
lib/momo/parameter.rb,
lib/momo/reference.rb,
lib/momo/memberreference.rb

Defined Under Namespace

Modules: MomoCondition Classes: BlockHash, BooleanValue, CFL, FuncCall, Mapping, MappingRow, MemberReference, MomoScope, Parameter, Reference, Resource, Stack

Constant Summary collapse

VERSION =
"0.4.1"

Class Method Summary collapse

Class Method Details

.cfl(&block) ⇒ Object



19
20
21
# File 'lib/momo.rb', line 19

def self.cfl(&block)
	Momo::CFL.new(&block)
end

.resolve(something, options = {}, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/momo/momoscope.rb', line 21

def Momo.resolve(something, options={}, &block)

	if something.is_a? String or 
		something.is_a? TrueClass or 
		something.is_a? FalseClass or
		something.is_a? Numeric
		return something
	elsif something.is_a? Array
		result = []
		something.each do |elem|
			result << Momo.resolve(elem, options)
		end
		return result 
	elsif something.is_a? Hash
		result = {}
		something.each do |key, value|
			result[key] = Momo.resolve(value, options)
		end
		return result
	elsif something.is_a? Resource
		return { "Ref" => something.name }
	elsif something.is_a? Reference
		return something.representation
	elsif something.is_a? BooleanValue
		return { "Condition" => something.signature }
	elsif something.is_a? FuncCall
		return something.representation
	elsif something.is_a? Parameter
		return { "Ref" => something.name }
	elsif something == nil && block
		return result = BlockHash.new(options, &block).props
	else
		raise "Invalid var: #{something.inspect} in #{options[:resource]}"
	end
end