Class: Spree::OrderPopulator
- Inherits:
-
Object
- Object
- Spree::OrderPopulator
- Defined in:
- app/models/spree/order_populator.rb
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#order ⇒ Object
Returns the value of attribute order.
Instance Method Summary collapse
-
#initialize(order, currency) ⇒ OrderPopulator
constructor
A new instance of OrderPopulator.
- #populate(variant_id, quantity) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(order, currency) ⇒ OrderPopulator
Returns a new instance of OrderPopulator.
6 7 8 9 10 |
# File 'app/models/spree/order_populator.rb', line 6 def initialize(order, currency) @order = order @currency = currency @errors = ActiveModel::Errors.new(self) end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
3 4 5 |
# File 'app/models/spree/order_populator.rb', line 3 def currency @currency end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
4 5 6 |
# File 'app/models/spree/order_populator.rb', line 4 def errors @errors end |
#order ⇒ Object
Returns the value of attribute order.
3 4 5 |
# File 'app/models/spree/order_populator.rb', line 3 def order @order end |
Instance Method Details
#populate(variant_id, quantity) ⇒ Object
12 13 14 15 16 |
# File 'app/models/spree/order_populator.rb', line 12 def populate(variant_id, quantity) attempt_cart_add(variant_id, quantity) order.ensure_updated_shipments valid? end |
#valid? ⇒ Boolean
18 19 20 |
# File 'app/models/spree/order_populator.rb', line 18 def valid? errors.empty? end |