Class: RecordStore::Changeset::Change
- Inherits:
-
Object
- Object
- RecordStore::Changeset::Change
- Defined in:
- lib/record_store/changeset.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#record ⇒ Object
Returns the value of attribute record.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #addition? ⇒ Boolean
-
#initialize(type: nil, record: nil, id: nil) ⇒ Change
constructor
A new instance of Change.
- #removal? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(type: nil, record: nil, id: nil) ⇒ Change
6 7 8 |
# File 'lib/record_store/changeset.rb', line 6 def initialize(type: nil, record: nil, id: nil) @type, @record, @id = type, record, id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/record_store/changeset.rb', line 4 def id @id end |
#record ⇒ Object
Returns the value of attribute record.
4 5 6 |
# File 'lib/record_store/changeset.rb', line 4 def record @record end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/record_store/changeset.rb', line 4 def type @type end |
Class Method Details
.addition(record) ⇒ Object
10 11 12 |
# File 'lib/record_store/changeset.rb', line 10 def self.addition(record) new(type: :addition, record: record) end |
.removal(record) ⇒ Object
14 15 16 |
# File 'lib/record_store/changeset.rb', line 14 def self.removal(record) new(type: :removal, record: record) end |
.update(id, record) ⇒ Object
18 19 20 21 |
# File 'lib/record_store/changeset.rb', line 18 def self.update(id, record) raise ArgumentError.new('id cannot be nil') if id.nil? new(type: :update, record: record, id: id) end |
Instance Method Details
#addition? ⇒ Boolean
27 28 29 |
# File 'lib/record_store/changeset.rb', line 27 def addition? type == :addition end |
#removal? ⇒ Boolean
23 24 25 |
# File 'lib/record_store/changeset.rb', line 23 def removal? type == :removal end |
#update? ⇒ Boolean
31 32 33 |
# File 'lib/record_store/changeset.rb', line 31 def update? type == :update end |