Class: Gaku::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gaku::User
- Defined in:
- app/models/gaku/user.rb
Instance Attribute Summary collapse
-
#login ⇒ Object
Returns the value of attribute login.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#login ⇒ Object
Returns the value of attribute login.
12 13 14 |
# File 'app/models/gaku/user.rb', line 12 def login @login end |
Class Method Details
.find_first_by_auth_conditions(warden_conditions) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/models/gaku/user.rb', line 26 def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) where(conditions).where(['lower(username) = :value OR lower(email) = :value', { value: login.downcase }]).first else where(conditions).first end end |
Instance Method Details
#has_role?(role_sym) ⇒ Boolean
35 36 37 |
# File 'app/models/gaku/user.rb', line 35 def has_role?(role_sym) roles.any? { |r| r.name.underscore.to_sym == role_sym } end |
#role?(role) ⇒ Boolean
39 40 41 |
# File 'app/models/gaku/user.rb', line 39 def role?(role) roles.detect {|p| p.name == role.to_s.camelize} end |
#to_s ⇒ Object
22 23 24 |
# File 'app/models/gaku/user.rb', line 22 def to_s username end |