Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/core/extensions/array.rb

Direct Known Subclasses

Kogno::BlockParams

Instance Method Summary collapse

Instance Method Details

#deep_symbolize_keys!Object



24
25
26
# File 'lib/core/extensions/array.rb', line 24

def deep_symbolize_keys!
  self.map{|h| h.deep_symbolize_keys!}
end

#replace_keys(defaults) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/core/extensions/array.rb', line 4

def replace_keys(defaults)
  new_a = []
  self.each do |v|
    if v.class == Array
      new_a << v.replace_keys(defaults)
    elsif v.class == Hash
      new_h = v
      defaults.each do |find,replace|
        # logger.debug "#{find} => #{replace}"
        # logger.debug "v:#{v}"
        new_h = new_h.transform_keys{|k| k == find ? replace : k}
      end
      new_a << new_h
    else
      new_a << v
    end
  end
  return(new_a)
end