Class: Spree::PromotionBuilder
- Inherits:
-
Object
- Object
- Spree::PromotionBuilder
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/spree/promotion_builder.rb
Instance Attribute Summary collapse
-
#base_code ⇒ Object
Returns the value of attribute base_code.
-
#number_of_codes ⇒ Object
Returns the value of attribute number_of_codes.
-
#promotion ⇒ Object
readonly
Returns the value of attribute promotion.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(attributes = {}, promotion_attributes = {}) ⇒ PromotionBuilder
constructor
A new instance of PromotionBuilder.
- #perform ⇒ Object
Constructor Details
#initialize(attributes = {}, promotion_attributes = {}) ⇒ PromotionBuilder
Returns a new instance of PromotionBuilder.
19 20 21 22 |
# File 'app/models/spree/promotion_builder.rb', line 19 def initialize(attributes={}, promotion_attributes={}) @promotion = Spree::Promotion.new(promotion_attributes) super(attributes) end |
Instance Attribute Details
#base_code ⇒ Object
Returns the value of attribute base_code.
5 6 7 |
# File 'app/models/spree/promotion_builder.rb', line 5 def base_code @base_code end |
#number_of_codes ⇒ Object
Returns the value of attribute number_of_codes.
5 6 7 |
# File 'app/models/spree/promotion_builder.rb', line 5 def number_of_codes @number_of_codes end |
#promotion ⇒ Object (readonly)
Returns the value of attribute promotion.
4 5 6 |
# File 'app/models/spree/promotion_builder.rb', line 4 def promotion @promotion end |
#user ⇒ Object
Returns the value of attribute user.
5 6 7 |
# File 'app/models/spree/promotion_builder.rb', line 5 def user @user end |
Instance Method Details
#perform ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/models/spree/promotion_builder.rb', line 24 def perform if can_build_codes? @promotion.codes = code_builder.build_promotion_codes end return false unless valid? @promotion.save end |