Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/issue_beaver/shared/hash.rb

Instance Method Summary collapse

Instance Method Details

#except(*blacklist) ⇒ Object



3
4
5
6
7
# File 'lib/issue_beaver/shared/hash.rb', line 3

def except(*blacklist)
  {}.tap do |h|
    (keys - blacklist - blacklist.map(&:to_s)).each { |k| h[k] = self[k] }
  end
end

#only(*whitelist) ⇒ Object



10
11
12
13
14
# File 'lib/issue_beaver/shared/hash.rb', line 10

def only(*whitelist)
  {}.tap do |h|
    (keys & (whitelist | whitelist.map(&:to_s))).each { |k| h[k] = self[k] }
  end
end