Class: Hash
Instance Method Summary collapse
Instance Method Details
#diff(other, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/redshift/util/object-diff.rb', line 43 def diff other, &block ha = (self.keys & other.keys).inject({}) do |h,k| h[k] = self[k].diff(other[k], &block); h end if block block.call ha, self.keys - other.keys, other.keys - self.keys end ha end |
#filter(&block) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/redshift/util/object-diff.rb', line 53 def filter(&block) ha = inject({}) do |h, (key, val)| v = val.filter(&block) h[key] = v if v h end ha.empty? ? nil : ha end |