Class: Clowne::Adapters::Sequel::Operation
- Inherits:
-
Utils::Operation
- Object
- Utils::Operation
- Clowne::Adapters::Sequel::Operation
- Includes:
- Ext::RecordKey
- Defined in:
- lib/clowne/adapters/sequel/operation.rb
Constant Summary
Constants inherited from Utils::Operation
Utils::Operation::DEFAULT_MAPPER
Instance Attribute Summary
Attributes inherited from Utils::Operation
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(mapper) ⇒ Operation
constructor
A new instance of Operation.
- #record_wrapper(record) ⇒ Object
- #to_record ⇒ Object
Methods included from Ext::RecordKey
Methods inherited from Utils::Operation
#add_after_clone, #add_after_persist, #add_mapping, clear!, current, #persist, #persist!, #run_after_clone, #run_after_persist, #save, #save!, wrap
Constructor Details
#initialize(mapper) ⇒ Operation
Returns a new instance of Operation.
10 11 12 13 |
# File 'lib/clowne/adapters/sequel/operation.rb', line 10 def initialize(mapper) super @records = {} end |
Instance Method Details
#hash ⇒ Object
19 20 21 |
# File 'lib/clowne/adapters/sequel/operation.rb', line 19 def hash @records[key(@clone)] end |
#record_wrapper(record) ⇒ Object
15 16 17 |
# File 'lib/clowne/adapters/sequel/operation.rb', line 15 def record_wrapper(record) @records[key(record)] ||= RecordWrapper.new(record) end |
#to_record ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/clowne/adapters/sequel/operation.rb', line 23 def to_record return @_record if defined?(@_record) record_wrapper(@clone) @_record = @records[key(@clone)].to_model.tap do run_after_clone end end |