Class: Tantot::Changes::ById

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_id) ⇒ ById

Returns a new instance of ById.



9
10
11
# File 'lib/tantot/changes.rb', line 9

def initialize(changes_by_id)
  @changes_by_id = changes_by_id
end

Instance Attribute Details

#changes_by_idObject (readonly)

Returns the value of attribute changes_by_id.



7
8
9
# File 'lib/tantot/changes.rb', line 7

def changes_by_id
  @changes_by_id
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/tantot/changes.rb', line 15

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

#attributesObject



27
28
29
# File 'lib/tantot/changes.rb', line 27

def attributes
  @changes_by_id.values.collect(&:keys).flatten.uniq.collect(&:to_sym)
end

#for_attribute(attribute, compact = true) ⇒ Object



19
20
21
# File 'lib/tantot/changes.rb', line 19

def for_attribute(attribute, compact = true)
  @changes_by_id.values.collect {|changes_by_attribute| changes_by_attribute[attribute.to_s]}.flatten.uniq.tap {|changes| changes.compact! if compact}
end

#idsObject



23
24
25
# File 'lib/tantot/changes.rb', line 23

def ids
  @changes_by_id.keys
end