Class: AuthLh::User

Inherits:
Object
  • Object
show all
Defined in:
lib/auth_lh/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ User

Returns a new instance of User.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/auth_lh/user.rb', line 9

def initialize(attributes={})
  attributes.each do |k,v|
    if k.to_s == 'external_apps'
      self.external_apps = v.map { |x| ExternalApp.new(x) }
    elsif k.to_s == 'roles'
      self.roles = v.map { |x| Role.new(x) }
    else
      self.send("#{k}=", v)
    end
  end
end

Instance Attribute Details

#attendance_modeObject

Returns the value of attribute attendance_mode.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def attendance_mode
  @attendance_mode
end

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def email
  @email
end

#enabledObject

Returns the value of attribute enabled.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def enabled
  @enabled
end

#extension_numberObject

Returns the value of attribute extension_number.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def extension_number
  @extension_number
end

#external_appsObject

Returns the value of attribute external_apps.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def external_apps
  @external_apps
end

#fingerprint_fromObject

Returns the value of attribute fingerprint_from.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def fingerprint_from
  @fingerprint_from
end

#fingerprint_toObject

Returns the value of attribute fingerprint_to.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def fingerprint_to
  @fingerprint_to
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def first_name
  @first_name
end

#has_remote_desktopObject

Returns the value of attribute has_remote_desktop.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def has_remote_desktop
  @has_remote_desktop
end

#jabberObject

Returns the value of attribute jabber.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def jabber
  @jabber
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def last_name
  @last_name
end

#local_app_shop_codesObject

Returns the value of attribute local_app_shop_codes.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def local_app_shop_codes
  @local_app_shop_codes
end

#loginObject

Returns the value of attribute login.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def 
  @login
end

#password_expiredObject

Returns the value of attribute password_expired.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def password_expired
  @password_expired
end

#rolesObject

Returns the value of attribute roles.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def roles
  @roles
end

#shop_codeObject

Returns the value of attribute shop_code.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def shop_code
  @shop_code
end

#shop_idObject

Returns the value of attribute shop_id.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def shop_id
  @shop_id
end

#shop_nameObject

Returns the value of attribute shop_name.



3
4
5
# File 'lib/auth_lh/user.rb', line 3

def shop_name
  @shop_name
end

Instance Method Details

#has_all_roles?(r_ids) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
# File 'lib/auth_lh/user.rb', line 39

def has_all_roles?(r_ids)
  r_ids.all? { |r_id|
    role_ids.include?(r_id.to_i)
  }
end

#has_role?(role_id) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/auth_lh/user.rb', line 29

def has_role?(role_id)
  role_ids.include?(role_id.to_i)
end

#has_some_role?(r_ids) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/auth_lh/user.rb', line 33

def has_some_role?(r_ids)
  r_ids.any? { |r_id|
    role_ids.include?(r_id.to_i)
  }
end

#nameObject



21
22
23
# File 'lib/auth_lh/user.rb', line 21

def name
  "#{first_name} #{last_name}"
end

#role_idsObject



25
26
27
# File 'lib/auth_lh/user.rb', line 25

def role_ids
  roles.map(&:id)
end