Sha256: 891c8c6d81f72592795adbd26fbabedcb03c52cd20419ac087e3df536e90e332
Contents?: true
Size: 1.73 KB
Versions: 15
Compression:
Stored size: 1.73 KB
Contents
module Lotus module Model module Adapters module Sql # Execute a command for the given query. # # @see Lotus::Model::Adapters::Sql::Query # # @api private # @since 0.1.0 class Command # Initialize a command # # @param query [Lotus::Model::Adapters::Sql::Query] # # @api private # @since 0.1.0 def initialize(query) @collection = query.scoped end # Creates a record for the given entity. # # @param entity [Object] the entity to persist # # @see Lotus::Model::Adapters::Sql::Collection#insert # # @return the primary key of the just created record. # # @api private # @since 0.1.0 def create(entity) @collection.insert(entity) end # Updates the corresponding record for the given entity. # # @param entity [Object] the entity to persist # # @see Lotus::Model::Adapters::Sql::Collection#update # # @api private # @since 0.1.0 def update(entity) @collection.update(entity) end # Deletes all the records for the current query. # # It's used to delete a single record or an entire database table. # # @see Lotus::Model::Adapters::SqlAdapter#delete # @see Lotus::Model::Adapters::SqlAdapter#clear # # @api private # @since 0.1.0 def delete @collection.delete end alias_method :clear, :delete end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems