Class: Spinoza::UpdateOperation

Inherits:
Operation show all
Defined in:
lib/spinoza/system/operation.rb

Instance Attribute Summary collapse

Attributes inherited from Operation

#table

Instance Method Summary collapse

Constructor Details

#initialize(txn = nil, table: nil, row: nil, key: nil) ⇒ UpdateOperation

Returns a new instance of UpdateOperation.



46
47
48
49
# File 'lib/spinoza/system/operation.rb', line 46

def initialize txn = nil, table: nil, row: nil, key: nil
  @txn = txn
  @table, @key, @row = table, key, row
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



45
46
47
# File 'lib/spinoza/system/operation.rb', line 45

def key
  @key
end

#rowObject (readonly)

Returns the value of attribute row.



45
46
47
# File 'lib/spinoza/system/operation.rb', line 45

def row
  @row
end

Instance Method Details

#check(lm) ⇒ Object



55
56
57
# File 'lib/spinoza/system/operation.rb', line 55

def check lm
  lm.has_write_lock? table, key, txn
end

#execute(ds) ⇒ Object



51
52
53
# File 'lib/spinoza/system/operation.rb', line 51

def execute ds
  ds.where(key).update(row)
end

#inspectObject



59
60
61
# File 'lib/spinoza/system/operation.rb', line 59

def inspect
  "<update #{table} #{key}: #{row}>"
end