Module: MassiveRecord::ORM::Persistence::Operations

Included in:
AtomicOperation, Destroy, Embedded::Destroy, Embedded::Insert, Embedded::Reload, Embedded::Update, Insert, Reload, Suppress, Update
Defined in:
lib/massive_record/orm/persistence/operations.rb,
lib/massive_record/orm/persistence/operations/insert.rb,
lib/massive_record/orm/persistence/operations/reload.rb,
lib/massive_record/orm/persistence/operations/update.rb,
lib/massive_record/orm/persistence/operations/destroy.rb,
lib/massive_record/orm/persistence/operations/suppress.rb,
lib/massive_record/orm/persistence/operations/embedded/insert.rb,
lib/massive_record/orm/persistence/operations/embedded/reload.rb,
lib/massive_record/orm/persistence/operations/embedded/update.rb,
lib/massive_record/orm/persistence/operations/atomic_operation.rb,
lib/massive_record/orm/persistence/operations/embedded/destroy.rb,
lib/massive_record/orm/persistence/operations/table_operation_helpers.rb,
lib/massive_record/orm/persistence/operations/embedded/operation_helpers.rb

Overview

The persistence Operations are in charge of inserting, updating and destroying records.

It’s reason for even existing is that we need to do these operations differently based on if we are saving a record which has a Table as it’s class or saving an embedded record.

The Persistence module will call upon Operations.insert(record, options) and execute on the returned object. Based on what kind of record we are getting in we can determine what kind of Operation object to return

Defined Under Namespace

Modules: Embedded, TableOperationHelpers Classes: AtomicOperation, Destroy, Insert, Reload, Suppress, Update

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



91
92
93
# File 'lib/massive_record/orm/persistence/operations.rb', line 91

def klass
  @klass
end

#optionsObject (readonly)

Returns the value of attribute options.



91
92
93
# File 'lib/massive_record/orm/persistence/operations.rb', line 91

def options
  @options
end

#recordObject (readonly)

Returns the value of attribute record.



91
92
93
# File 'lib/massive_record/orm/persistence/operations.rb', line 91

def record
  @record
end

Class Method Details

.atomic_operation(record, options = {}) ⇒ Object



65
66
67
# File 'lib/massive_record/orm/persistence/operations.rb', line 65

def atomic_operation(record, options = {})
  operator_for :atomic_operation, record, options
end

.destroy(record, options = {}) ⇒ Object



61
62
63
# File 'lib/massive_record/orm/persistence/operations.rb', line 61

def destroy(record, options = {})
  operator_for :destroy, record, options
end

.forceObject



41
42
43
44
45
46
# File 'lib/massive_record/orm/persistence/operations.rb', line 41

def force
  suppressed_was, @suppressed = @suppressed, false
  yield
ensure
  @suppressed = suppressed_was
end

.insert(record, options = {}) ⇒ Object



53
54
55
# File 'lib/massive_record/orm/persistence/operations.rb', line 53

def insert(record, options = {})
  operator_for :insert, record, options
end

.reload(record, options = {}) ⇒ Object



69
70
71
# File 'lib/massive_record/orm/persistence/operations.rb', line 69

def reload(record, options = {})
  operator_for :reload, record, options
end

.suppressObject



34
35
36
37
38
39
# File 'lib/massive_record/orm/persistence/operations.rb', line 34

def suppress
  suppressed_was, @suppressed = @suppressed, true
  yield
ensure
  @suppressed = suppressed_was
end

.suppressed?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/massive_record/orm/persistence/operations.rb', line 48

def suppressed?
  !!@suppressed
end

.update(record, options = {}) ⇒ Object



57
58
59
# File 'lib/massive_record/orm/persistence/operations.rb', line 57

def update(record, options = {})
  operator_for :update, record, options
end

Instance Method Details

#executeObject



101
102
103
# File 'lib/massive_record/orm/persistence/operations.rb', line 101

def execute
  raise "Not implemented"
end

#initialize(record, options = {}) ⇒ Object



94
95
96
97
98
# File 'lib/massive_record/orm/persistence/operations.rb', line 94

def initialize(record, options = {})
  @record = record
  @klass = record.class
  @options = options
end