Class: Gaku::User

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/gaku/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loginObject

Returns the value of attribute login.



12
13
14
# File 'app/models/gaku/user.rb', line 12

def 
  @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  = conditions.delete(:login)
    where(conditions).where(['lower(username) = :value OR lower(email) = :value', { value: .downcase }]).first
  else
    where(conditions).first
  end
end

Instance Method Details

#has_role?(role_sym) ⇒ Boolean

Returns:

  • (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

Returns:

  • (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_sObject



22
23
24
# File 'app/models/gaku/user.rb', line 22

def to_s
  username
end