Module: DiscoApp::Concerns::Subscription
- Extended by:
- ActiveSupport::Concern
- Included in:
- Subscription
- Defined in:
- app/models/disco_app/concerns/subscription.rb
Instance Method Summary collapse
-
#active_charge ⇒ Object
Convenience method to get the active charge for this subscription.
-
#active_charge? ⇒ Boolean
Convenience method to check if this subscription has an active charge.
- #charge_class ⇒ Object
-
#charges ⇒ Object
Return the appropriate set of charges for this subscription’s type.
-
#requires_active_charge? ⇒ Boolean
Only require an active charge if the amount to be charged is > 0.
- #shopify_charge_class ⇒ Object
Instance Method Details
#active_charge ⇒ Object
Convenience method to get the active charge for this subscription.
33 34 35 |
# File 'app/models/disco_app/concerns/subscription.rb', line 33 def active_charge charges.active.first end |
#active_charge? ⇒ Boolean
Convenience method to check if this subscription has an active charge.
28 29 30 |
# File 'app/models/disco_app/concerns/subscription.rb', line 28 def active_charge? active_charge.present? end |
#charge_class ⇒ Object
42 43 44 |
# File 'app/models/disco_app/concerns/subscription.rb', line 42 def charge_class recurring? ? DiscoApp::RecurringApplicationCharge : DiscoApp::ApplicationCharge end |
#charges ⇒ Object
Return the appropriate set of charges for this subscription’s type.
38 39 40 |
# File 'app/models/disco_app/concerns/subscription.rb', line 38 def charges recurring? ? recurring_charges : one_time_charges end |
#requires_active_charge? ⇒ Boolean
Only require an active charge if the amount to be charged is > 0.
23 24 25 |
# File 'app/models/disco_app/concerns/subscription.rb', line 23 def requires_active_charge? amount > 0 end |
#shopify_charge_class ⇒ Object
46 47 48 |
# File 'app/models/disco_app/concerns/subscription.rb', line 46 def shopify_charge_class recurring? ? ShopifyAPI::RecurringApplicationCharge : ShopifyAPI::ApplicationCharge end |