Class: ROM::Changeset Abstract
- Inherits:
-
Object
- Object
- ROM::Changeset
- Extended by:
- Dry::Core::Cache, Dry::Core::ClassAttributes, Initializer
- Defined in:
- lib/rom/repository/changeset.rb,
lib/rom/repository/changeset/pipe.rb,
lib/rom/repository/changeset/create.rb,
lib/rom/repository/changeset/delete.rb,
lib/rom/repository/changeset/update.rb,
lib/rom/repository/changeset/stateful.rb,
lib/rom/repository/changeset/associated.rb,
lib/rom/repository/changeset/restricted.rb
Overview
Abstract Changeset class
If you inherit from this class you need to configure additional settings
Defined Under Namespace
Modules: PipeRegistry, Restricted Classes: Associated, Create, Delete, Pipe, Stateful, Update
Constant Summary collapse
- DEFAULT_COMMAND_OPTS =
{ mapper: false }.freeze
Instance Attribute Summary collapse
-
#command_compiler ⇒ Proc
readonly
A proc that can compile a command (typically provided by a repo).
-
#command_type ⇒ Symbol
readonly
A custom command identifier.
-
#relation ⇒ Relation
readonly
The changeset relation.
Class Method Summary collapse
-
.[](relation_name) ⇒ Object
Create a changeset class preconfigured for a specific relation.
-
.command_type ⇒ Object
Get or set changeset command type.
-
.relation ⇒ Object
Get or set changeset relation identifier.
Instance Method Summary collapse
-
#command ⇒ ROM::Command
private
Return a command for this changeset.
-
#commit ⇒ Hash, Array
Persist changeset.
-
#inspect ⇒ String
Return string representation of the changeset.
-
#with(new_options) ⇒ Changeset
Return a new changeset with updated options.
Instance Attribute Details
#command_compiler ⇒ Proc (readonly)
Returns a proc that can compile a command (typically provided by a repo).
56 |
# File 'lib/rom/repository/changeset.rb', line 56 option :command_compiler, reader: true, optional: true |
#command_type ⇒ Symbol (readonly)
Returns a custom command identifier.
60 |
# File 'lib/rom/repository/changeset.rb', line 60 option :command_type, reader: true, default: -> changeset { changeset.class.command_type } |
#relation ⇒ Relation (readonly)
Returns The changeset relation.
52 |
# File 'lib/rom/repository/changeset.rb', line 52 param :relation |
Class Method Details
.[](relation_name) ⇒ Object
Create a changeset class preconfigured for a specific relation
71 72 73 74 75 |
# File 'lib/rom/repository/changeset.rb', line 71 def self.[](relation_name) fetch_or_store([relation_name, self]) { Class.new(self) { relation(relation_name) } } end |
.command_type ⇒ Symbol .command_type(identifier) ⇒ Symbol
Get or set changeset command type
35 |
# File 'lib/rom/repository/changeset.rb', line 35 defines :command_type |
.relation ⇒ Symbol .relation(identifier) ⇒ Symbol
Get or set changeset relation identifier
48 |
# File 'lib/rom/repository/changeset.rb', line 48 defines :relation |
Instance Method Details
#command ⇒ ROM::Command
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return a command for this changeset
123 124 125 |
# File 'lib/rom/repository/changeset.rb', line 123 def command command_compiler.(command_type, relation_identifier, DEFAULT_COMMAND_OPTS) end |
#commit ⇒ Hash, Array
Persist changeset
105 106 107 |
# File 'lib/rom/repository/changeset.rb', line 105 def commit command.call end |
#inspect ⇒ String
Return string representation of the changeset
114 115 116 |
# File 'lib/rom/repository/changeset.rb', line 114 def inspect %(#<#{self.class} relation=#{relation.name.inspect}>) end |
#with(new_options) ⇒ Changeset
Return a new changeset with updated options
91 92 93 |
# File 'lib/rom/repository/changeset.rb', line 91 def with() self.class.new(relation, .merge()) end |