Class: Spree::CouponCodes::CouponCodesHandler
- Inherits:
-
Object
- Object
- Spree::CouponCodes::CouponCodesHandler
- Defined in:
- app/services/spree/coupon_codes/coupon_codes_handler.rb
Instance Attribute Summary collapse
-
#codes ⇒ Object
readonly
Returns the value of attribute codes.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
-
#initialize(order:) ⇒ CouponCodesHandler
constructor
A new instance of CouponCodesHandler.
- #use_all_codes ⇒ Object
Constructor Details
#initialize(order:) ⇒ CouponCodesHandler
Returns a new instance of CouponCodesHandler.
6 7 8 9 |
# File 'app/services/spree/coupon_codes/coupon_codes_handler.rb', line 6 def initialize(order:) @order = order @codes = Spree::CouponCode.where(order_id: order.id) end |
Instance Attribute Details
#codes ⇒ Object (readonly)
Returns the value of attribute codes.
4 5 6 |
# File 'app/services/spree/coupon_codes/coupon_codes_handler.rb', line 4 def codes @codes end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
4 5 6 |
# File 'app/services/spree/coupon_codes/coupon_codes_handler.rb', line 4 def order @order end |
Instance Method Details
#use_all_codes ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/services/spree/coupon_codes/coupon_codes_handler.rb', line 11 def use_all_codes return unless codes.any? promotion_ids = find_current_promotions_ids use_all_current(promotion_ids) clear_all_unused(promotion_ids) end |