Class: Lotus::Model::Adapters::Sql::Command Private
- Inherits:
-
Object
- Object
- Lotus::Model::Adapters::Sql::Command
- Defined in:
- lib/lotus/model/adapters/sql/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 query.
Instance Method Summary collapse
-
#create(entity) ⇒ Object
private
Creates a record for the given entity.
-
#delete ⇒ Object
(also: #clear)
private
Deletes all the records for the current query.
-
#initialize(query) ⇒ Command
constructor
private
Initialize a command.
-
#update(entity) ⇒ Object
private
Updates the corresponding record for the given entity.
Constructor Details
#initialize(query) ⇒ 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
18 19 20 |
# File 'lib/lotus/model/adapters/sql/command.rb', line 18 def initialize(query) @collection = query.scoped end |
Instance Method Details
#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.
32 33 34 35 36 |
# File 'lib/lotus/model/adapters/sql/command.rb', line 32 def create(entity) @collection.insert(entity) rescue Sequel::DatabaseError => e raise Lotus::Model::Error.new(e.) end |
#delete ⇒ Object Also known as: clear
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 for the current query.
It’s used to delete a single record or an entire database table.
61 62 63 64 65 |
# File 'lib/lotus/model/adapters/sql/command.rb', line 61 def delete @collection.delete rescue Sequel::DatabaseError => e raise Lotus::Model::Error.new(e.) 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.
46 47 48 49 50 |
# File 'lib/lotus/model/adapters/sql/command.rb', line 46 def update(entity) @collection.update(entity) rescue Sequel::DatabaseError => e raise Lotus::Model::Error.new(e.) end |