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



162
163
164
165
166
167
168
169
170
171
172
# File 'lib/convection/model/template.rb', line 162

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