Class: User

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

Constant Summary collapse

EMAIL_NAME_REGEX =
'[\w\.%\+\-]+'.freeze
DOMAIN_HEAD_REGEX =
'(?:[A-Z0-9\-]+\.)+'.freeze
DOMAIN_TLD_REGEX =
'(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|jobs|museum)'.freeze
EMAIL_REGEX =
/\A#{EMAIL_NAME_REGEX}@#{DOMAIN_HEAD_REGEX}#{DOMAIN_TLD_REGEX}\z/i

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#first_nameObject

Profile



74
75
76
# File 'app/models/user.rb', line 74

def first_name
  @first_name
end

#last_nameObject

Profile



74
75
76
# File 'app/models/user.rb', line 74

def last_name
  @last_name
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'app/models/user.rb', line 7

def name
  @name
end

#stateObject



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

def state; @state ||= 'inactive' end

Class Method Details

.[](name) ⇒ Object



85
86
87
# File 'app/models/user.rb', line 85

def [] name
  by_name name.to_s
end

.avatar_url(user_name) ⇒ Object



91
92
93
# File 'app/models/user.rb', line 91

def avatar_url user_name
  "#{rad.users.avatars_path}/avatars/#{user_name}.icon"
end

Instance Method Details

#activateObject



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

def activate; self.state = 'active' end

#active?Boolean

Returns:

  • (Boolean)


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

def active?; state == 'active' end

#dom_idObject



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

def dom_id; "user: #{super}" end

#inactivateObject



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

def inactivate; self.state = 'inactive' end

#inactive?Boolean

Returns:

  • (Boolean)


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

def inactive?; state == 'inactive' end

#slugObject



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

def slug; name end

#to_paramObject

Other



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

def to_param; name end