Class: Forminator::Step
- Inherits:
-
Object
- Object
- Forminator::Step
- Includes:
- Hanami::Validations
- Defined in:
- lib/forminator/step.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
11 12 13 |
# File 'lib/forminator/step.rb', line 11 def object @object end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
11 12 13 |
# File 'lib/forminator/step.rb', line 11 def params @params end |
Class Method Details
.call(object, params, **options) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/forminator/step.rb', line 13 def self.call(object, params, **) step = new(params) validity = step.valid? if validity && step.persist? step.persist(object: object, persist: [:persist]) end [{ valid: validity }, params] end |
Instance Method Details
#persist(object:, persist: nil) ⇒ Object
31 32 33 34 |
# File 'lib/forminator/step.rb', line 31 def persist(object:, persist: nil) persist&.call(object) || Forminator.config.persist.call(object) end |
#persist? ⇒ Boolean
27 28 29 |
# File 'lib/forminator/step.rb', line 27 def persist? false end |
#valid? ⇒ Boolean
23 24 25 |
# File 'lib/forminator/step.rb', line 23 def valid? validate.success? end |