Class: Spree::PromotionCode::BatchBuilder
- Inherits:
-
Object
- Object
- Spree::PromotionCode::BatchBuilder
- Defined in:
- app/models/spree/promotion_code/batch_builder.rb
Instance Attribute Summary collapse
-
#promotion_code_batch ⇒ Object
readonly
Returns the value of attribute promotion_code_batch.
Instance Method Summary collapse
- #build_promotion_codes ⇒ Object
-
#initialize(promotion_code_batch) ⇒ BatchBuilder
constructor
A new instance of BatchBuilder.
Constructor Details
#initialize(promotion_code_batch) ⇒ BatchBuilder
Returns a new instance of BatchBuilder.
11 12 13 |
# File 'app/models/spree/promotion_code/batch_builder.rb', line 11 def initialize(promotion_code_batch) @promotion_code_batch = promotion_code_batch end |
Instance Attribute Details
#promotion_code_batch ⇒ Object (readonly)
Returns the value of attribute promotion_code_batch.
2 3 4 |
# File 'app/models/spree/promotion_code/batch_builder.rb', line 2 def promotion_code_batch @promotion_code_batch end |
Instance Method Details
#build_promotion_codes ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/spree/promotion_code/batch_builder.rb', line 15 def build_promotion_codes generate_random_codes promotion_code_batch.update!(state: "completed") rescue => e promotion_code_batch.update!( error: e.inspect, state: "failed" ) raise e end |