Class: User

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
app/models/user.rb

Constant Summary collapse

PER_PAGE =
30

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.token_authentication_keyObject


88
89
90
# File 'app/models/user.rb', line 88

def self.token_authentication_key
  :auth_token
end

Instance Method Details

#can_create_github_issues?Boolean

Returns:

  • (Boolean)

71
72
73
# File 'app/models/user.rb', line 71

def can_create_github_issues?
  github_account? && Errbit::Config.github_access_scope.include?('repo')
end

#encrypted_passwordObject

Devise field Database Authenticatable


18
# File 'app/models/user.rb', line 18

field :encrypted_password, :type => String

#ensure_authentication_tokenObject


82
83
84
85
86
# File 'app/models/user.rb', line 82

def ensure_authentication_token
  if authentication_token.blank?
    self.authentication_token = generate_authentication_token
  end
end

#github_account?Boolean

Returns:

  • (Boolean)

67
68
69
# File 'app/models/user.rb', line 67

def github_account?
  .present? && github_oauth_token.present?
end

#github_login=(login) ⇒ Object


75
76
77
78
79
80
# File 'app/models/user.rb', line 75

def github_login=()
  if .is_a?(String) && .strip.empty?
     = nil
  end
  self[:github_login] = 
end

#password_required?Boolean

Returns:

  • (Boolean)

63
64
65
# File 'app/models/user.rb', line 63

def password_required?
  .present? ? false : super
end

#per_pageObject


55
56
57
# File 'app/models/user.rb', line 55

def per_page
  super || PER_PAGE
end

#watchersObject


51
52
53
# File 'app/models/user.rb', line 51

def watchers
  apps.map(&:watchers).flatten.select {|w| w.user_id.to_s == id.to_s}
end

#watching?(app) ⇒ Boolean

Returns:

  • (Boolean)

59
60
61
# File 'app/models/user.rb', line 59

def watching?(app)
  apps.all.include?(app)
end