Module: StackMate::Intrinsic
- Included in:
- CloudStackOutput
- Defined in:
- lib/stackmate/intrinsic_functions.rb
Instance Method Summary collapse
- #fn_getatt(array_value, workitem) ⇒ Object
- #fn_join(value, workitem) ⇒ Object
- #fn_ref(value, workitem) ⇒ Object
- #fn_select(array_value) ⇒ Object
- #intrinsic(hash, workitem) ⇒ Object
Instance Method Details
#fn_getatt(array_value, workitem) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/stackmate/intrinsic_functions.rb', line 38 def fn_getatt(array_value, workitem) resource = array_value[0] attribute = array_value[1] #logger.debug "Intrinsic: fn_getatt resource= #{resource} attrib = #{attribute} wi[Resource] = #{workitem[resource]}" workitem[resource][attribute] end |
#fn_join(value, workitem) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stackmate/intrinsic_functions.rb', line 20 def fn_join(value, workitem) delim = value[0] v = value[1] #logger.debug "Intrinsic: fn_join value = #{v}" result = '' first_ = true v.each do |token| case token when String result = result + (first_ ? "" : delim) + token when Hash result = result + (first_ ? "" : delim) + intrinsic(token, workitem) end first_ = false end result end |
#fn_ref(value, workitem) ⇒ Object
52 53 54 55 |
# File 'lib/stackmate/intrinsic_functions.rb', line 52 def fn_ref(value, workitem) #logger.debug "Intrinsic: fn_ref value = #{value}" workitem[value]['physical_id'] #TODO only works with Resources not Params end |
#fn_select(array_value) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/stackmate/intrinsic_functions.rb', line 45 def fn_select(array_value) index = array_value[0].to_i #TODO unsafe values = array_value[1] #logger.debug "Intrinsic: fn_select index= #{index} values = #{values.inspect}" values[index] end |
#intrinsic(hash, workitem) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/stackmate/intrinsic_functions.rb', line 4 def intrinsic (hash, workitem) key = hash.keys[0] value = hash[key] #logger.debug "Intrinsic: key = #{key}, value = #{value}" case key when 'Fn::Join' fn_join(value, workitem) when 'Fn::GetAtt' fn_getatt(value, workitem) when 'Fn::Select' fn_select(value) when 'Ref' fn_ref(value, workitem) end end |