Class: Lotus::Model::Adapters::Memory::Command Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/model/adapters/memory/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.

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(dataset, collection) ⇒ 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

Parameters:

Since:

  • 0.1.0



20
21
22
23
# File 'lib/lotus/model/adapters/memory/command.rb', line 20

def initialize(dataset, collection)
  @dataset    = dataset
  @collection = collection
end

Instance Method Details

#clearObject

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 all the records from the table.



75
76
77
# File 'lib/lotus/model/adapters/memory/command.rb', line 75

def clear
  @dataset.clear
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.

Parameters:

  • entity (Object)

    the entity to persist

Returns:

  • the primary key of the just created record.

See Also:

  • Lotus::Model::Adapters::Memory::Collection#insert

Since:

  • 0.1.0



35
36
37
38
39
40
# File 'lib/lotus/model/adapters/memory/command.rb', line 35

def create(entity)
  serialized_entity            = _serialize(entity)
  serialized_entity[_identity] = @dataset.create(serialized_entity)

  _deserialize(serialized_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.

Parameters:

  • entity (Object)

    the entity to delete

See Also:

Since:

  • 0.1.0



65
66
67
# File 'lib/lotus/model/adapters/memory/command.rb', line 65

def delete(entity)
  @dataset.delete(entity)
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.

Parameters:

  • entity (Object)

    the entity to persist

See Also:

Since:

  • 0.1.0



50
51
52
53
54
55
# File 'lib/lotus/model/adapters/memory/command.rb', line 50

def update(entity)
  serialized_entity = _serialize(entity)
  @dataset.update(serialized_entity)

  _deserialize(serialized_entity)
end