Class: User

Inherits:
Object
  • Object
show all
Includes:
MongoMapper::Document
Defined in:
lib/rad/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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](name) ⇒ Object



129
130
131
# File 'lib/rad/models/user.rb', line 129

def [] name
  find_by_name name.to_s
end

.currentObject



137
138
139
# File 'lib/rad/models/user.rb', line 137

def current
  Thread.current['current_user'].must_be.defined
end

.current=(current) ⇒ Object



133
134
135
# File 'lib/rad/models/user.rb', line 133

def current= current
  Thread.current['current_user'] = current
end

.current?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/rad/models/user.rb', line 141

def current?
  Thread.current['current_user'] != nil
end

Instance Method Details

#email=(value) ⇒ Object



20
21
22
23
# File 'lib/rad/models/user.rb', line 20

def email= value
  # write_attribute :email, (value ? value.downcase : nil)
  super(value ? value.downcase : nil)
end

#name=(value) ⇒ Object



15
16
17
18
# File 'lib/rad/models/user.rb', line 15

def name= value
  # write_attribute :name, (value ? value.downcase : nil)
  super(value ? value.downcase : nil)
end

#slugObject



157
# File 'lib/rad/models/user.rb', line 157

def slug; name end

#to_paramObject



152
# File 'lib/rad/models/user.rb', line 152

def to_param; name end