Class: Misty::Auth::Name

Inherits:
Struct
  • Object
show all
Defined in:
lib/misty/auth/name.rb

Direct Known Subclasses

DomainScope, ProjectScope, User

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



20
21
22
# File 'lib/misty/auth/name.rb', line 20

def id
  @id
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



20
21
22
# File 'lib/misty/auth/name.rb', line 20

def name
  @name
end

Instance Method Details

#identityObject



21
22
23
24
25
# File 'lib/misty/auth/name.rb', line 21

def identity
  return to_h(:id) unless id.nil?
  return to_h(:name) unless name.nil?
  raise Misty::Config::CredentialsError, "#{self.class}: No available id or name"
end

#to_h(var) ⇒ Object



27
28
29
# File 'lib/misty/auth/name.rb', line 27

def to_h(var)
  { var => self.send(var) }
end