Class: Map

Inherits:
Object
  • Object
show all
Defined in:
lib/basilik/core_ext/map.rb

Constant Summary collapse

Event =
Value.new( :event_type, :ref )

Instance Method Summary collapse

Instance Method Details

#diff(other) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/basilik/core_ext/map.rb', line 5

def diff(other)
  res = dup.
    delete_if { |k, v| other[k] == v }.
    merge!(other.dup.delete_if { |k, v| has_key?(k) })
  events = []  
  res.each_pair do |k,v|
    if self[k]
      if other[k]
        events << Event.new( Basilik::Load.evt_value, k ) 
      else
        events << Event.new( Basilik::Load.evt_child_removed, k )
      end
    else
      events << Event.new( Basilik::Load.evt_child_added, k )
    end
  end
  events
end