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