Class: Tantot::Changes::ByModel

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/tantot/changes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(changes_by_model) ⇒ ByModel

Returns a new instance of ByModel.



37
38
39
# File 'lib/tantot/changes.rb', line 37

def initialize(changes_by_model)
  @changes_by_model = changes_by_model
end

Instance Attribute Details

#changes_by_modelObject (readonly)

Returns the value of attribute changes_by_model.



35
36
37
# File 'lib/tantot/changes.rb', line 35

def changes_by_model
  @changes_by_model
end

Instance Method Details

#==(other) ⇒ Object



44
45
46
# File 'lib/tantot/changes.rb', line 44

def ==(other)
  other.changes_by_model == @changes_by_model
end

#[](model) ⇒ Object



48
49
50
# File 'lib/tantot/changes.rb', line 48

def [](model)
  for_model(model)
end

#each(&block) ⇒ Object



52
53
54
55
56
# File 'lib/tantot/changes.rb', line 52

def each(&block)
  @changes_by_model.each do |model, changes|
    block.call(model, Tantot::Changes::ById.new(changes))
  end
end

#for_model(model) ⇒ Object



58
59
60
# File 'lib/tantot/changes.rb', line 58

def for_model(model)
  Tantot::Changes::ById.new(@changes_by_model[model])
end