Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/convection/model/template.rb

Overview

HACK: Add generic diff(other) and properties to Hash and Array

Instance Method Summary collapse

Instance Method Details

#properties(memo = {}, path = '') ⇒ Object

Recursivly flatten an array into 1st order key/value pairs



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/convection/model/template.rb', line 124

def properties(memo = {}, path = '')
  each_with_index do |elm, i|
    if elm.is_a?(Hash) || elm.is_a?(Array)
      elm.properties(memo, "#{path}.#{i}")
    else
      memo["#{path}.#{i}"] = elm
    end
  end

  memo
end