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
82
83
84
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 82
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
86
87
88
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 86
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
51
52
53
54
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 51
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
45
46
47
48
49
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 45
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
56
57
58
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 56
def subscription_active?
subscribed? && subscription_status == EffectiveOrders::ACTIVE
end
|
#subscription_past_due? ⇒ Boolean
60
61
62
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 60
def subscription_past_due?
subscribed? && subscription_status == EffectiveOrders::PAST_DUE
end
|
#subscription_trialing? ⇒ Boolean
65
66
67
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 65
def subscription_trialing?
subscribed? && subscription_status == EffectiveOrders::TRIALING
end
|
#trial_active? ⇒ Boolean
74
75
76
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 74
def trial_active?
trialing? && trialing_until > Time.zone.now
end
|
#trial_past_due? ⇒ Boolean
78
79
80
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 78
def trial_past_due?
trialing? && trialing_until < Time.zone.now
end
|
#trialing? ⇒ Boolean
70
71
72
|
# File 'app/models/concerns/acts_as_subscribable.rb', line 70
def trialing?
subscription_status.blank?
end
|