Module: ROM::Plugins::Relation::Changeset::InstanceMethods
- Defined in:
- changeset/lib/rom/plugins/relation/changeset.rb
Overview
Relation instance methods provided by the Changeset plugin
Instance Method Summary collapse
-
#changeset(type, data = EMPTY_HASH) ⇒ Object
Create a changeset for a relation.
Instance Method Details
#changeset(type, data) ⇒ Changeset #changeset(changeset_class, data) ⇒ Changeset
Create a changeset for a relation
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'changeset/lib/rom/plugins/relation/changeset.rb', line 83 def changeset(type, data = EMPTY_HASH) klass = type.is_a?(Symbol) ? TYPES.fetch(type) : type unless klass < ROM::Changeset raise ArgumentError, "+#{type.name}+ must be a Changeset descendant" end if klass < ROM::Changeset::Stateful klass.new(self, __data__: data) else klass.new(self) end rescue KeyError raise ArgumentError, "+#{type.inspect}+ is not a valid changeset type. Must be one of: #{TYPES.keys.inspect}" end |