Module: Payola::AsyncBehavior
- Extended by:
- ActiveSupport::Concern
- Included in:
- SubscriptionsController, TransactionsController
- Defined in:
- app/controllers/concerns/payola/async_behavior.rb
Instance Method Summary collapse
- #create_object(object_class, object_creator_class, object_processor_class, product_key, product) ⇒ Object
- #object_status(object_class) ⇒ Object
- #show_object(object_class) ⇒ Object
Instance Method Details
#create_object(object_class, object_creator_class, object_processor_class, product_key, product) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/concerns/payola/async_behavior.rb', line 18 def create_object(object_class, object_creator_class, object_processor_class, product_key, product) create_params = if object_class == Subscription params.permit!.merge( product_key => product, coupon: @coupon, quantity: @quantity, affiliate: @affiliate ) else params.permit!.merge( product_key => product, coupon: @coupon, affiliate: @affiliate ) end object = object_creator_class.call(create_params) if object.save && object_processor_class.present? Payola.queue!(object_processor_class, object.guid) end render_payola_status(object) end |
#object_status(object_class) ⇒ Object
13 14 15 16 |
# File 'app/controllers/concerns/payola/async_behavior.rb', line 13 def object_status(object_class) object = object_class.find_by(guid: params[:guid]) render_payola_status(object) end |
#show_object(object_class) ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/controllers/concerns/payola/async_behavior.rb', line 5 def show_object(object_class) object = object_class.find_by!(guid: params[:guid]) redirector = object.redirector new_path = redirector.respond_to?(:redirect_path) ? redirector.redirect_path(object) : '/' redirect_to new_path end |