Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/gclouder/monkey_patches/array.rb

Instance Method Summary collapse

Instance Method Details

#cleanObject



4
5
6
# File 'lib/gclouder/monkey_patches/array.rb', line 4

def clean
  uniq.delete_if(&:nil?)
end

#fetch_with_default(key, name, default) ⇒ Object



15
16
17
18
# File 'lib/gclouder/monkey_patches/array.rb', line 15

def fetch_with_default(key, name, default)
  results = find { |e| e[key] == name }
  results || default
end

#to_snake_keysObject



8
9
10
11
12
13
# File 'lib/gclouder/monkey_patches/array.rb', line 8

def to_snake_keys
  each_with_index do |v, i|
    self[i] = v.to_snake_keys if v.is_a?(Hash)
  end
  self
end