Class: RecordStore::Changeset::Change

Inherits:
Object
  • Object
show all
Defined in:
lib/record_store/changeset.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: nil, record: nil, id: nil) ⇒ Change

Returns a new instance of Change.



6
7
8
9
10
# File 'lib/record_store/changeset.rb', line 6

def initialize(type: nil, record: nil, id: nil)
  @type = type
  @record = record
  @id = id
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/record_store/changeset.rb', line 4

def id
  @id
end

#recordObject

Returns the value of attribute record.



4
5
6
# File 'lib/record_store/changeset.rb', line 4

def record
  @record
end

#typeObject

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



13
14
15
# File 'lib/record_store/changeset.rb', line 13

def addition(record)
  new(type: :addition, record: record)
end

.removal(record) ⇒ Object



17
18
19
# File 'lib/record_store/changeset.rb', line 17

def removal(record)
  new(type: :removal, record: record)
end

.update(id, record) ⇒ Object



21
22
23
# File 'lib/record_store/changeset.rb', line 21

def update(id, record)
  new(type: :update, record: record, id: id)
end

Instance Method Details

#addition?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/record_store/changeset.rb', line 30

def addition?
  type == :addition
end

#removal?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/record_store/changeset.rb', line 26

def removal?
  type == :removal
end

#update?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/record_store/changeset.rb', line 34

def update?
  type == :update
end