Class: Obsidian::Rails::ModelUpdateTracker::Delta

Inherits:
Object
  • Object
show all
Defined in:
lib/obsidian/rails/model_update_tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDelta

Returns a new instance of Delta.



9
10
11
# File 'lib/obsidian/rails/model_update_tracker.rb', line 9

def initialize
  reset
end

Instance Attribute Details

#committedObject

Returns the value of attribute committed.



8
9
10
# File 'lib/obsidian/rails/model_update_tracker.rb', line 8

def committed
  @committed
end

#uncommittedObject

Returns the value of attribute uncommitted.



8
9
10
# File 'lib/obsidian/rails/model_update_tracker.rb', line 8

def uncommitted
  @uncommitted
end

Instance Method Details

#<<(obj) ⇒ Object



18
19
20
# File 'lib/obsidian/rails/model_update_tracker.rb', line 18

def << (obj)
  @uncommitted << obj
end

#class_namesObject



35
36
37
38
39
40
41
# File 'lib/obsidian/rails/model_update_tracker.rb', line 35

def class_names
  set = instances.inject(Set.new) do |set,inst|
    set << inst.class.to_s
    set
  end
  set
end

#instancesObject



31
32
33
# File 'lib/obsidian/rails/model_update_tracker.rb', line 31

def instances
  @committed + @uncommitted
end

#resetObject



13
14
15
16
# File 'lib/obsidian/rails/model_update_tracker.rb', line 13

def reset
  @committed = []
  @uncommitted = []
end

#transaction_committedObject



22
23
24
25
# File 'lib/obsidian/rails/model_update_tracker.rb', line 22

def transaction_committed
  @committed = @committed + @uncommitted
  @uncommitted = []
end

#transaction_rolled_backObject



27
28
29
# File 'lib/obsidian/rails/model_update_tracker.rb', line 27

def transaction_rolled_back
  @uncommitted = []
end