Class: Hash

Inherits:
Object show all
Defined in:
merb-core/lib/merb-core/core_ext/hash.rb,
merb-cache/lib/merb-cache/core_ext/hash.rb

Instance Method Summary (collapse)

Instance Method Details

- (Array<Object>) extract!(*args)

Returns the value of self for each argument and deletes those entries.

Parameters:

  • *args

    The keys whose values should be extracted and deleted.

Returns:

  • (Array<Object>)

    The values of the provided arguments in corresponding order.



10
11
12
13
14
# File 'merb-core/lib/merb-core/core_ext/hash.rb', line 10

def extract!(*args)
  args.map do |arg|
    self.delete(arg)
  end
end

- (Object) to_sha2



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'merb-cache/lib/merb-cache/core_ext/hash.rb', line 5

def to_sha2
  string = ""
  keys.sort_by{|k| k.to_s}.each do |k| 
    case self[k]
    when Array
      string << self[k].join
    when Hash
      string << self[k].to_sha2
    else
      string << self[k].to_s
    end
  end
  Digest::SHA2.hexdigest(string)
end