Class: Spree::Checkout::Step
- Inherits:
-
Object
- Object
- Spree::Checkout::Step
- Defined in:
- app/models/spree/checkout/step.rb
Overview
Value object representing a custom checkout step registered via Registry.
Instance Attribute Summary collapse
-
#after ⇒ String?
readonly
Name of the checkout step this should be placed after.
-
#before ⇒ String?
readonly
Name of the checkout step this should be placed before.
-
#name ⇒ String
readonly
Step name.
Instance Method Summary collapse
-
#applicable?(order) ⇒ Boolean
Whether this step applies to the given order.
-
#initialize(name:, satisfied:, requirements:, applicable: ->(_) { true }, after: nil, before: nil) ⇒ Step
constructor
A new instance of Step.
-
#requirements(order) ⇒ Array<Hash{Symbol => String}>
Outstanding requirement hashes (+{ step:, field:, message: }+).
-
#satisfied?(order) ⇒ Boolean
Whether the step’s conditions have been met.
Constructor Details
#initialize(name:, satisfied:, requirements:, applicable: ->(_) { true }, after: nil, before: nil) ⇒ Step
Returns a new instance of Step.
30 31 32 33 34 35 36 37 |
# File 'app/models/spree/checkout/step.rb', line 30 def initialize(name:, satisfied:, requirements:, applicable: ->(_) { true }, after: nil, before: nil) @name = name.to_s @after = after&.to_s @before = before&.to_s @satisfied_proc = satisfied @requirements_proc = requirements @applicable_proc = applicable end |
Instance Attribute Details
#after ⇒ String? (readonly)
Returns name of the checkout step this should be placed after.
17 18 19 |
# File 'app/models/spree/checkout/step.rb', line 17 def after @after end |
#before ⇒ String? (readonly)
Returns name of the checkout step this should be placed before.
20 21 22 |
# File 'app/models/spree/checkout/step.rb', line 20 def before @before end |
#name ⇒ String (readonly)
Returns step name.
14 15 16 |
# File 'app/models/spree/checkout/step.rb', line 14 def name @name end |
Instance Method Details
#applicable?(order) ⇒ Boolean
Returns whether this step applies to the given order.
49 |
# File 'app/models/spree/checkout/step.rb', line 49 def applicable?(order) = @applicable_proc.call(order) |
#requirements(order) ⇒ Array<Hash{Symbol => String}>
Returns outstanding requirement hashes (+{ step:, field:, message: }+).
45 |
# File 'app/models/spree/checkout/step.rb', line 45 def requirements(order) = @requirements_proc.call(order) |
#satisfied?(order) ⇒ Boolean
Returns whether the step’s conditions have been met.
41 |
# File 'app/models/spree/checkout/step.rb', line 41 def satisfied?(order) = @satisfied_proc.call(order) |