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.
- #as_json(options = {}) ⇒ Object
- #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.
40 41 42 |
# File 'app/models/disco_app/concerns/subscription.rb', line 40 def active_charge charges.active.first end |
#active_charge? ⇒ Boolean
Convenience method to check if this subscription has an active charge.
35 36 37 |
# File 'app/models/disco_app/concerns/subscription.rb', line 35 def active_charge? active_charge.present? end |
#as_json(options = {}) ⇒ Object
57 58 59 60 61 |
# File 'app/models/disco_app/concerns/subscription.rb', line 57 def as_json( = {}) super.merge( 'active_charge' => active_charge ) end |
#charge_class ⇒ Object
49 50 51 |
# File 'app/models/disco_app/concerns/subscription.rb', line 49 def charge_class recurring? ? DiscoApp::RecurringApplicationCharge : DiscoApp::ApplicationCharge end |
#charges ⇒ Object
Return the appropriate set of charges for this subscription’s type.
45 46 47 |
# File 'app/models/disco_app/concerns/subscription.rb', line 45 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.
30 31 32 |
# File 'app/models/disco_app/concerns/subscription.rb', line 30 def requires_active_charge? amount > 0 end |
#shopify_charge_class ⇒ Object
53 54 55 |
# File 'app/models/disco_app/concerns/subscription.rb', line 53 def shopify_charge_class recurring? ? ShopifyAPI::RecurringApplicationCharge : ShopifyAPI::ApplicationCharge end |