Module: StateGate::Builder::TransitionValidationMethods
- Included in:
- StateGate::Builder
- Defined in:
- lib/state_gate/builder/transition_validation_methods.rb
Overview
Description
Multiple private methods allowing StateGate::Builder to generate attribute setter methods for transition validation.
-
initializing the attribute with
Class.new:Klass.new(status: :active) #=> ArgumentError -
initializing the attribute with
Class.create:Klass.create(status: :active) #=> ArgumentError -
initializing the attribute with
Class.create!:Klass.create!(status: :active) #=> ArgumentError -
setting the attribute with
attr=:.status = :active #=> :active .status = :archived #=> ArgumentError -
setting the attribute with
[:attr]=:[:status] = :active #=> :active [:status] = :archived #=> ArgumentError -
setting the attribute with
attributes=:.attrubutes = {status: :active} #=> :active .attributes = {status: :archived } #=> ArgumentError -
setting the attribute with
assign_attributes:.assign_attrubutes(status: :active) #=> :active .assign_attributes(status: :archived) #=> ArgumentError -
updating the attribute with
Class.update:Klass.update(instance.id, status: :active) #=> :active Klass.update(instance.id, status: :archived) #=> ArgumentError -
updating the attribute with
.update:.update(status: :active) #=> :active .update(status: :archived) #=> ArgumentError -
updating the attribute with
.update_column:.update_column(:status, :active) #=> :active .update_column(:status, :archived) #=> ArgumentError -
updating the attribute with
.update_columns:.update_columns(status: :active) #=> :active .update_columns(status: :archived) #=> ArgumentError -
updating the attribute with
.write_attribute:.write_attribute(:status, :active) #=> :active .write_attribute(:status, :archived) #=> ArgumentError
| Forcing a change
To force a status change that would otherwise be prohibited, preceed the new state with force_ :
.status = :archived #=> ArgumentError
.status = :force_archived #=> :archived