Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/slim_scrooge/monitored_hash.rb

Overview

We need to change the update method of Hash so that it always calls to_hash on MonitoredHash instances. This is because it normally checks if other_hash is a kind of Hash, and doesn’t bother calling to_hash if so. But we need it to call to_hash, because otherwise update will not get the complete columns from a MonitoredHash

This is not harmful - to_hash in a regular Hash just returns self.

Instance Method Summary collapse

Instance Method Details

#c_updateObject



100
# File 'lib/slim_scrooge/monitored_hash.rb', line 100

alias_method :c_update, :update

#update(other_hash, &block) ⇒ Object



101
102
103
104
# File 'lib/slim_scrooge/monitored_hash.rb', line 101

def update(other_hash, &block)
  c_update(other_hash.is_a?(::SlimScrooge::MonitoredHash) ? other_hash.to_hash : other_hash,
           &block)
end