Class: ROM::Changeset Abstract
- Inherits:
-
Object
- Object
- ROM::Changeset
- Extended by:
- Dry::Core::Cache, Dry::Core::ClassAttributes, Initializer
- Defined in:
- lib/rom/changeset.rb,
lib/rom/changeset/pipe.rb,
lib/rom/changeset/create.rb,
lib/rom/changeset/delete.rb,
lib/rom/changeset/update.rb,
lib/rom/changeset/version.rb,
lib/rom/changeset/stateful.rb,
lib/rom/changeset/associated.rb
Overview
Abstract Changeset class
If you inherit from this class you need to configure additional settings
Defined Under Namespace
Modules: PipeRegistry Classes: Associated, Create, Delete, Pipe, Stateful, Update
Constant Summary collapse
- DEFAULT_COMMAND_OPTS =
{ mapper: false }.freeze
- VERSION =
'1.0.2'.freeze
Instance Attribute Summary collapse
-
#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.
-
#new(relation, new_options = EMPTY_HASH) ⇒ Changeset
Return a new changeset with provided relation.
Instance Attribute Details
#command_type ⇒ Symbol (readonly)
Returns a custom command identifier.
57 |
# File 'lib/rom/changeset.rb', line 57 option :command_type, default: -> { self.class.command_type } |
#relation ⇒ Relation (readonly)
Returns The changeset relation.
53 |
# File 'lib/rom/changeset.rb', line 53 param :relation |
Class Method Details
.[](relation_name) ⇒ Object
Create a changeset class preconfigured for a specific relation
68 69 70 71 72 |
# File 'lib/rom/changeset.rb', line 68 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
36 |
# File 'lib/rom/changeset.rb', line 36 defines :command_type |
.relation ⇒ Symbol .relation(identifier) ⇒ Symbol
Get or set changeset relation identifier
49 |
# File 'lib/rom/changeset.rb', line 49 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
116 117 118 |
# File 'lib/rom/changeset.rb', line 116 def command relation.command(command_type, DEFAULT_COMMAND_OPTS) end |
#commit ⇒ Hash, Array
Persist changeset
98 99 100 |
# File 'lib/rom/changeset.rb', line 98 def commit command.call end |
#inspect ⇒ String
Return string representation of the changeset
107 108 109 |
# File 'lib/rom/changeset.rb', line 107 def inspect %(#<#{self.class} relation=#{relation.name.inspect}>) end |
#new(relation, new_options = EMPTY_HASH) ⇒ Changeset
Return a new changeset with provided relation
New options can be provided too
84 85 86 |
# File 'lib/rom/changeset.rb', line 84 def new(relation, = EMPTY_HASH) self.class.new(relation, .empty? ? : .merge()) end |