Class: Tantot::Changes::ById
- Inherits:
-
Object
- Object
- Tantot::Changes::ById
- Includes:
- Enumerable
- Defined in:
- lib/tantot/changes.rb
Instance Attribute Summary collapse
-
#changes_by_id ⇒ Object
readonly
Returns the value of attribute changes_by_id.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attributes ⇒ Object
- #for_attribute(attribute, compact = true) ⇒ Object
- #ids ⇒ Object
-
#initialize(changes_by_id) ⇒ ById
constructor
A new instance of ById.
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_id ⇒ Object (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 |
#attributes ⇒ Object
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 |
#ids ⇒ Object
23 24 25 |
# File 'lib/tantot/changes.rb', line 23 def ids @changes_by_id.keys end |