Class: Wbase::Subscription
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Wbase::Subscription
- Defined in:
- app/models/wbase/subscription.rb
Class Method Summary collapse
Instance Method Summary collapse
- #current? ⇒ Boolean
- #monthly_value ⇒ Object
- #stripe_customer ⇒ Object
- #trial? ⇒ Boolean
- #trial_days_left ⇒ Object
Class Method Details
.current ⇒ Object
30 31 32 |
# File 'app/models/wbase/subscription.rb', line 30 def self.current where('paid_thru > ?', 7.days.ago) end |
Instance Method Details
#current? ⇒ Boolean
51 52 53 |
# File 'app/models/wbase/subscription.rb', line 51 def current? paid_thru && paid_thru > 7.days.ago end |
#monthly_value ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/models/wbase/subscription.rb', line 43 def monthly_value if plan.interval.include?("month") current_price else current_price.fdiv(12) end end |
#stripe_customer ⇒ Object
34 35 36 |
# File 'app/models/wbase/subscription.rb', line 34 def stripe_customer @stripe_customer ||= Stripe::Customer.retrieve(stripe_id) end |
#trial? ⇒ Boolean
55 56 57 |
# File 'app/models/wbase/subscription.rb', line 55 def trial? created_at > 14.days.ago end |
#trial_days_left ⇒ Object
59 60 61 62 |
# File 'app/models/wbase/subscription.rb', line 59 def trial_days_left return 0 unless trial? (conversion_day.to_date - Date.current.to_date).to_i end |