Module: ROM::Relation::Commands
- Included in:
- ROM::Relation, Combined
- Defined in:
- core/lib/rom/relation/commands.rb
Overview
Extensions for relation classes which provide access to commands
Instance Method Summary collapse
-
#command(type, mapper: nil, use: EMPTY_ARRAY, plugins_options: EMPTY_HASH, **opts) ⇒ ROM::Command
Return a command for the relation.
Instance Method Details
#command(type, mapper: nil, use: EMPTY_ARRAY, plugins_options: EMPTY_HASH, **opts) ⇒ ROM::Command
Return a command for the relation
This method can either return an existing custom command identified
by type
param, or generate a command dynamically based on relation
AST.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'core/lib/rom/relation/commands.rb', line 40 def command(type, mapper: nil, use: EMPTY_ARRAY, plugins_options: EMPTY_HASH, **opts) base_command = if commands.key?(type) commands[type] else commands[type, adapter, to_ast, use, , opts] end command = if mapper base_command >> mappers[mapper] elsif auto_map? base_command >> self.mapper else base_command end if command.restrictible? command.new(self) else command end end |