Sha256: ff201c66aa83e2218080aeb066166d04a6d7470c287567219d064fc01ef5129c
Contents?: true
Size: 1.09 KB
Versions: 7
Compression:
Stored size: 1.09 KB
Contents
require 'rom/commands' module ROM module Memory # Memory adapter commands namespace # # @api public module Commands # In-memory create command # # @api public class Create < ROM::Commands::Create # @see ROM::Commands::Create#execute def execute(tuple) attributes = input[tuple] validator.call(attributes) [relation.insert(attributes.to_h).to_a.last] end end # In-memory update command # # @api public class Update < ROM::Commands::Update # @see ROM::Commands::Update#execute def execute(params) attributes = input[params] validator.call(attributes) relation.map { |tuple| tuple.update(attributes.to_h) } end end # In-memory delete command # # @api public class Delete < ROM::Commands::Delete # @see ROM::Commands::Delete#execute def execute tuples = target.to_a tuples.each { |tuple| relation.delete(tuple) } tuples end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems