Class: Spree::Checkout::Requirements
- Inherits:
-
Object
- Object
- Spree::Checkout::Requirements
- Defined in:
- app/models/spree/checkout/requirements.rb
Overview
Aggregates all checkout requirements for an order.
Combines built-in checks from DefaultRequirements with custom steps and requirements registered in Registry. The resulting array of hashes is exposed on the Cart API as the requirements attribute.
Each requirement hash has the shape:
{ step: String, field: String, message: String }
Instance Method Summary collapse
-
#call ⇒ Array<Hash{Symbol => String}>
All unmet requirements.
-
#initialize(order) ⇒ Requirements
constructor
A new instance of Requirements.
-
#met? ⇒ Boolean
True when all requirements are satisfied.
Constructor Details
#initialize(order) ⇒ Requirements
Returns a new instance of Requirements.
18 19 20 |
# File 'app/models/spree/checkout/requirements.rb', line 18 def initialize(order) @order = order end |
Instance Method Details
#call ⇒ Array<Hash{Symbol => String}>
Returns all unmet requirements.
23 24 25 |
# File 'app/models/spree/checkout/requirements.rb', line 23 def call default + from_registered_steps + from_additional_requirements end |
#met? ⇒ Boolean
Returns true when all requirements are satisfied.
28 29 30 |
# File 'app/models/spree/checkout/requirements.rb', line 28 def met? call.empty? end |