Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/ckick/array.rb,
lib/ckick/hash_elements.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#array_aware_deep_transform_keys(&block) ⇒ Object

transforms any Hash key recursively

  • block - transform operation



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ckick/array.rb', line 11

def array_aware_deep_transform_keys(&block)
  result = []
  each do |value|
    if value.is_a?(Hash) || value.is_a?(Array)
      result << value.array_aware_deep_transform_keys(&block)
    else
      result << value
    end
  end
  result
end

#to_hash_elementObject

converts to hash-serializable value



48
49
50
51
52
53
54
55
56
# File 'lib/ckick/hash_elements.rb', line 48

def to_hash_element
  collect do |element|
    if element.respond_to?(:to_hash)
      element.to_hash
    else
      element.to_hash_element
    end
  end
end