Class: ROM::Changeset Abstract
- Inherits:
-
Object
- Object
- ROM::Changeset
- Extended by:
- Dry::Core::Cache, Dry::Core::ClassAttributes, Initializer
- Defined in:
- changeset/lib/rom/changeset.rb,
changeset/lib/rom/changeset/pipe.rb,
changeset/lib/rom/changeset/create.rb,
changeset/lib/rom/changeset/delete.rb,
changeset/lib/rom/changeset/update.rb,
changeset/lib/rom/changeset/version.rb,
changeset/lib/rom/changeset/stateful.rb,
changeset/lib/rom/changeset/associated.rb,
changeset/lib/rom/changeset/pipe_registry.rb,
changeset/lib/rom/changeset/extensions/relation.rb
Overview
Abstract Changeset class
If you inherit from this class you need to configure additional settings
Defined Under Namespace
Modules: Extensions, PipeRegistry Classes: Associated, Create, Delete, Pipe, Stateful, Update
Constant Summary collapse
- VERSION =
'5.3.0'
Instance Attribute Summary collapse
-
#command_options ⇒ Hash
readonly
Configured options for the command.
-
#command_plugins ⇒ Hash
readonly
Configured plugin options for the command.
-
#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_options ⇒ Object
Get or set command options.
-
.command_plugins ⇒ Object
Get or set command plugins options.
-
.command_type ⇒ Object
Get or set changeset command type.
-
.relation ⇒ Object
Get or set changeset relation identifier.
-
.use(plugin, **options) ⇒ Object
Enable a plugin for the changeset.
Instance Method Summary collapse
-
#command ⇒ ROM::Command
private
Return a command for this changeset.
-
#command_compiler_options ⇒ Hash
private
Return configured command compiler options.
-
#commit ⇒ Hash, Array
Persist changeset.
-
#inspect ⇒ String
Return string representation of the changeset.
-
#new(relation, **new_options) ⇒ Changeset
Return a new changeset with provided relation.
Instance Attribute Details
#command_options ⇒ Hash (readonly)
Returns Configured options for the command.
85 |
# File 'changeset/lib/rom/changeset.rb', line 85 option :command_options, default: -> { self.class. } |
#command_plugins ⇒ Hash (readonly)
Returns Configured plugin options for the command.
89 |
# File 'changeset/lib/rom/changeset.rb', line 89 option :command_plugins, default: -> { self.class.command_plugins } |
#command_type ⇒ Symbol (readonly)
Returns a custom command identifier.
81 |
# File 'changeset/lib/rom/changeset.rb', line 81 option :command_type, default: -> { self.class.command_type } |
#relation ⇒ Relation (readonly)
Returns The changeset relation.
77 |
# File 'changeset/lib/rom/changeset.rb', line 77 param :relation |
Class Method Details
.[](relation_name) ⇒ Object
Create a changeset class preconfigured for a specific relation
106 107 108 109 110 |
# File 'changeset/lib/rom/changeset.rb', line 106 def self.[](relation_name) fetch_or_store([relation_name, self]) { Class.new(self) { relation(relation_name) } } end |
.command_options ⇒ Hash? .command_options(**options) ⇒ Hash
Get or set command options
47 |
# File 'changeset/lib/rom/changeset.rb', line 47 defines :command_options |
.command_plugins ⇒ Hash? .command_plugins(**options) ⇒ Hash
Get or set command plugins options
60 |
# File 'changeset/lib/rom/changeset.rb', line 60 defines :command_plugins |
.command_type ⇒ Symbol .command_type(identifier) ⇒ Symbol
Get or set changeset command type
34 |
# File 'changeset/lib/rom/changeset.rb', line 34 defines :command_type |
.relation ⇒ Symbol .relation(identifier) ⇒ Symbol
Get or set changeset relation identifier
73 |
# File 'changeset/lib/rom/changeset.rb', line 73 defines :relation |
.use(plugin, **options) ⇒ Object
Enable a plugin for the changeset
115 116 117 |
# File 'changeset/lib/rom/changeset.rb', line 115 def self.use(plugin, **) ROM.plugin_registry[:changeset].fetch(plugin).apply_to(self, **) end |
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
161 162 163 |
# File 'changeset/lib/rom/changeset.rb', line 161 def command relation.command(command_type, **) end |
#command_compiler_options ⇒ Hash
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 configured command compiler options
170 171 172 |
# File 'changeset/lib/rom/changeset.rb', line 170 def .merge(use: command_plugins.keys, plugins_options: command_plugins) end |
#commit ⇒ Hash, Array
Persist changeset
143 144 145 |
# File 'changeset/lib/rom/changeset.rb', line 143 def commit command.call end |
#inspect ⇒ String
Return string representation of the changeset
152 153 154 |
# File 'changeset/lib/rom/changeset.rb', line 152 def inspect %(#<#{self.class} relation=#{relation.name.inspect}>) end |
#new(relation, **new_options) ⇒ Changeset
Return a new changeset with provided relation
New options can be provided too
129 130 131 |
# File 'changeset/lib/rom/changeset.rb', line 129 def new(relation, **) self.class.new(relation, **, **) end |