Sha256: b7a82f083bc4469c2369be592c3f5d0f8b2ccce009ea8c45d6ec29368cb7332a
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
module ROM class Relation # Extensions for relation classes which provide access to commands # # @api public module Commands # Return a command for the relation # # @example # users.command(:create) # # @param type [Symbol] The command type (:create, :update or :delete) # @option :mapper [ROM::Mapper] An optional mapper applied to the command result # @option :use [Array<Symbol>] A list of command plugins # @option :result [:one, :many] Whether the command result has one or more rows. # :one is default # # @return [ROM::Command] # # @api public def command(type, mapper: nil, use: EMPTY_ARRAY, **opts) base_command = commands[type, adapter, to_ast, use, opts] command = if mapper base_command >> mappers[mapper] elsif mappers.any? && !base_command.is_a?(CommandProxy) mappers.reduce(base_command) { |a, (_, e)| a >> e } elsif auto_struct? || auto_map? base_command >> self.mapper else base_command end if command.restrictible? command.new(self) else command end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rom-core-4.0.0.rc1 | lib/rom/relation/commands.rb |
rom-core-4.0.0.beta3 | lib/rom/relation/commands.rb |