Sha256: fc47ebc319186db212a985d00a164fe9ecb1ccb6dfe1a44ea304c24c7bf2cdda
Contents?: true
Size: 697 Bytes
Versions: 1
Compression:
Stored size: 697 Bytes
Contents
require 'rom/fmp/commands' #require 'rom/fmp/commands/transaction' module ROM module FMP module Commands class Create < ROM::Commands::Create #include Transaction def execute(tuples) insert_tuples = Array([tuples]).flatten.map do |tuple| attributes = input[tuple] validator.call(attributes) attributes.to_h end insert(insert_tuples) rescue *ERRORS => e raise ConstraintError, e.message end def insert(tuples) pks = tuples.map { |tuple| relation.insert(tuple) } relation.where(relation.primary_key => pks) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-fmp-0.0.4 | lib/rom/fmp/commands/create.rb |