Class: AuthLh::UserExtended

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UserExtended

Returns a new instance of UserExtended.



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

def initialize(attributes={})
  attributes.each do |k,v|
    if k.to_s == 'external_apps'
      self.external_apps = v.map { |x| ExternalAppExtended.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

#allow_multiple_sessionsObject

Returns the value of attribute allow_multiple_sessions.



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

def allow_multiple_sessions
  @allow_multiple_sessions
end

#allow_remote_accessObject

Returns the value of attribute allow_remote_access.



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

def allow_remote_access
  @allow_remote_access
end

#attendance_modeObject

Returns the value of attribute attendance_mode.



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

def attendance_mode
  @attendance_mode
end

#disable_timeObject

Returns the value of attribute disable_time.



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

def disable_time
  @disable_time
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#enabledObject

Returns the value of attribute enabled.



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

def enabled
  @enabled
end

#external_appsObject

Returns the value of attribute external_apps.



3
4
5
# File 'lib/auth_lh/user_extended.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_extended.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_extended.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_extended.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_extended.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_extended.rb', line 3

def jabber
  @jabber
end

#last_nameObject

Returns the value of attribute last_name.



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

def last_name
  @last_name
end

#loginObject

Returns the value of attribute login.



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

def 
  @login
end

#only_working_timeObject

Returns the value of attribute only_working_time.



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

def only_working_time
  @only_working_time
end

#password_digestObject

Returns the value of attribute password_digest.



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

def password_digest
  @password_digest
end

#password_expiredObject

Returns the value of attribute password_expired.



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

def password_expired
  @password_expired
end

#password_remember_enabledObject

Returns the value of attribute password_remember_enabled.



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

def password_remember_enabled
  @password_remember_enabled
end

#pending_password_refreshObject

Returns the value of attribute pending_password_refresh.



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

def pending_password_refresh
  @pending_password_refresh
end

#rolesObject

Returns the value of attribute roles.



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

def roles
  @roles
end

#session_timeoutObject

Returns the value of attribute session_timeout.



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

def session_timeout
  @session_timeout
end

#shop_codeObject

Returns the value of attribute shop_code.



3
4
5
# File 'lib/auth_lh/user_extended.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_extended.rb', line 3

def shop_id
  @shop_id
end

#testing_userObject

Returns the value of attribute testing_user.



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

def testing_user
  @testing_user
end

#working_timeObject

Returns the value of attribute working_time.



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

def working_time
  @working_time
end

Instance Method Details

#app_codesObject



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

def app_codes
  external_apps.map(&:code)
end

#has_all_roles?(r_ids) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
47
# File 'lib/auth_lh/user_extended.rb', line 43

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)


33
34
35
# File 'lib/auth_lh/user_extended.rb', line 33

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

#has_some_role?(r_ids) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
# File 'lib/auth_lh/user_extended.rb', line 37

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_extended.rb', line 21

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

#role_idsObject



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

def role_ids
  roles.map(&:id)
end