Class: Lotus::Model::Adapters::Dynamodb::Command Private
- Inherits:
-
Object
- Object
- Lotus::Model::Adapters::Dynamodb::Command
- Defined in:
- lib/lotus/model/adapters/dynamodb/command.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Execute a command for the given collection.
Instance Method Summary collapse
-
#_serialize(entity) ⇒ Hash
private
private
Serialize the given entity before to persist in the database.
-
#create(entity) ⇒ Object
private
Creates a record for the given entity.
-
#delete(entity) ⇒ Object
private
Deletes the corresponding record for the given entity.
-
#get(key) ⇒ Object
private
Returns an unique record from the given collection, with the given id.
-
#initialize(dataset, collection) ⇒ Lotus::Model::Adapters::Dynamodb::Command
constructor
private
Initialize a command.
-
#update(entity) ⇒ Object
private
Updates the corresponding record for the given entity.
Constructor Details
#initialize(dataset, collection) ⇒ Lotus::Model::Adapters::Dynamodb::Command
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a command.
22 23 24 |
# File 'lib/lotus/model/adapters/dynamodb/command.rb', line 22 def initialize(dataset, collection) @dataset, @collection = dataset, collection end |
Instance Method Details
#_serialize(entity) ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Serialize the given entity before to persist in the database.
96 97 98 99 |
# File 'lib/lotus/model/adapters/dynamodb/command.rb', line 96 def _serialize(entity) serialized = @collection.serialize(entity) serialized.delete_if { |_, v| v.nil? } end |
#create(entity) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a record for the given entity.
36 37 38 39 40 |
# File 'lib/lotus/model/adapters/dynamodb/command.rb', line 36 def create(entity) @dataset.create( _serialize(entity) ) end |
#delete(entity) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Deletes the corresponding record for the given entity.
64 65 66 67 68 |
# File 'lib/lotus/model/adapters/dynamodb/command.rb', line 64 def delete(entity) @dataset.delete( _serialize(entity) ) end |
#get(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an unique record from the given collection, with the given id.
81 82 83 84 85 |
# File 'lib/lotus/model/adapters/dynamodb/command.rb', line 81 def get(key) @collection.deserialize( [@dataset.get(key)].compact ).first end |
#update(entity) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Updates the corresponding record for the given entity.
50 51 52 53 54 |
# File 'lib/lotus/model/adapters/dynamodb/command.rb', line 50 def update(entity) @dataset.update( _serialize(entity) ) end |