Class: Hoss::Context::User Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, email: nil, username: nil) ⇒ User

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of User.



24
25
26
27
28
# File 'lib/hoss/context/user.rb', line 24

def initialize(id: nil, email: nil, username: nil)
  @id = id
  @email = email
  @username = username
end

Instance Attribute Details

#emailObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/hoss/context/user.rb', line 40

def email
  @email
end

#idObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/hoss/context/user.rb', line 40

def id
  @id
end

#usernameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/hoss/context/user.rb', line 40

def username
  @username
end

Class Method Details

.infer(config, record) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
36
37
38
# File 'lib/hoss/context/user.rb', line 30

def self.infer(config, record)
  return unless record

  new(
    id: safe_get(record, config.current_user_id_method)&.to_s,
    email: safe_get(record, config.current_user_email_method),
    username: safe_get(record, config.current_user_username_method)
  )
end

Instance Method Details

#any?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


46
47
48
# File 'lib/hoss/context/user.rb', line 46

def any?
  !empty?
end

#empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


42
43
44
# File 'lib/hoss/context/user.rb', line 42

def empty?
  !id && !email && !username
end