Class: Clerk

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

Constant Summary collapse

PEPPER =
"0bfa9e2cb4a5efd0d976518a3d82e345060547913d2fd1dd2f32b0c8dbbbb5d3dc20b86d0fed31aca9513bccdf51643700ea277d9c64d9ce8ef886bf39293453"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'app/models/clerk.rb', line 5

def password
  @password
end

#password_confirmationObject

Returns the value of attribute password_confirmation.



5
6
7
# File 'app/models/clerk.rb', line 5

def password_confirmation
  @password_confirmation
end

Instance Method Details

#valid_password?(password) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
# File 'app/models/clerk.rb', line 21

def valid_password?(password)
  return false if password.blank? 
  encrypted = encrypt_password(password)
  return false if self.encrypted_password.blank? || encrypted.bytesize != self.encrypted_password.bytesize
  left = encrypted.unpack "C#{encrypted.bytesize}"
  res = 0
  self.encrypted_password.each_byte { |byte| res |= byte ^ left.shift }
  res == 0
end

#whole_addressObject



17
18
19
# File 'app/models/clerk.rb', line 17

def whole_address
  [ name , street , city , phone ].join(" ")
end