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, options = {}) ⇒ 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, options = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/models/spree/order_populator.rb', line 12 def populate(variant_id, quantity, = {}) ActiveSupport::Deprecation.warn "OrderPopulator is deprecated and will be removed from Spree 3, use OrderContents with order.contents.add instead.", caller # protect against passing a nil hash being passed in # due to an empty params[:options] attempt_cart_add(variant_id, quantity, || {}) valid? end |
#valid? ⇒ Boolean
20 21 22 |
# File 'app/models/spree/order_populator.rb', line 20 def valid? errors.empty? end |