Module: ActsAsSubscribable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/acts_as_subscribable.rb
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary
collapse
Instance Method Details
#subscribable_buyer ⇒ Object
83
84
85
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 83
def subscribable_buyer
raise 'acts_as_subscribable object requires the subscribable_buyer method be defined to return the User buying this item.'
end
|
#subscribable_quantity_used ⇒ Object
87
88
89
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 87
def subscribable_quantity_used
raise 'acts_as_subscribable object requires the subscribable_quantity_used method be defined to determine how many are in use.'
end
|
#subscribed?(stripe_plan_id = nil) ⇒ Boolean
52
53
54
55
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 52
def subscribed?(stripe_plan_id = nil)
return false if subscription_status.blank?
stripe_plan_id ? (subscription&.stripe_plan_id == stripe_plan_id) : true
end
|
#subscripter ⇒ Object
46
47
48
49
50
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 46
def subscripter
@_effective_subscripter ||= begin
Effective::Subscripter.new(subscribable: self, user: subscribable_buyer, quantity: subscription&.quantity, stripe_plan_id: subscription&.stripe_plan_id)
end
end
|
#subscription_active? ⇒ Boolean
57
58
59
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 57
def subscription_active?
subscribed? && subscription_status == EffectiveOrders::ACTIVE
end
|
#subscription_past_due? ⇒ Boolean
61
62
63
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 61
def subscription_past_due?
subscribed? && subscription_status == EffectiveOrders::PAST_DUE
end
|
#subscription_trialing? ⇒ Boolean
66
67
68
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 66
def subscription_trialing?
subscribed? && subscription_status == EffectiveOrders::TRIALING
end
|
#trial_active? ⇒ Boolean
75
76
77
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 75
def trial_active?
trialing? && trialing_until > Time.zone.now
end
|
#trial_past_due? ⇒ Boolean
79
80
81
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 79
def trial_past_due?
trialing? && trialing_until < Time.zone.now
end
|
#trialing? ⇒ Boolean
71
72
73
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 71
def trialing?
subscription_status.blank?
end
|