Class: Spinoza::ReadOperation

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

Instance Attribute Summary collapse

Attributes inherited from Operation

#table

Instance Method Summary collapse

Methods inherited from Operation

#check

Constructor Details

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

Returns a new instance of ReadOperation.



82
83
84
85
# File 'lib/spinoza/system/operation.rb', line 82

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



81
82
83
# File 'lib/spinoza/system/operation.rb', line 81

def key
  @key
end

Instance Method Details

#execute(ds) ⇒ Object



87
88
89
# File 'lib/spinoza/system/operation.rb', line 87

def execute ds
  ReadResult.new(op: self, val: ds.where(key).first)
end

#inspectObject



91
92
93
# File 'lib/spinoza/system/operation.rb', line 91

def inspect
  "<read #{table} #{key}>"
end