Class: Soar::Registry::Identity::Provider::Staff::Base

Inherits:
SoarIdm::IdmApi
  • Object
show all
Defined in:
lib/soar/registry/identity/provider/staff/base.rb

Direct Known Subclasses

Email, Id

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory: nil) ⇒ Base

Returns a new instance of Base.

Parameters:

  • directory (Hash) (defaults to: nil)

    directory configuration



17
18
19
20
# File 'lib/soar/registry/identity/provider/staff/base.rb', line 17

def initialize(directory: nil)
  @translator = Soar::Registry::Identity::Provider::Staff::Translator::Default.new
  @directory = directory
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



11
12
13
# File 'lib/soar/registry/identity/provider/staff/base.rb', line 11

def directory
  @directory
end

#translatorObject (readonly)

Returns the value of attribute translator.



12
13
14
# File 'lib/soar/registry/identity/provider/staff/base.rb', line 12

def translator
  @translator
end

Instance Method Details

#calculate_all_attributes(identity) ⇒ Hash

Returns Hash of attributes keyed by role.

Parameters:

  • identity (Hash)

Returns:

  • (Hash)

    Hash of attributes keyed by role



65
66
67
68
# File 'lib/soar/registry/identity/provider/staff/base.rb', line 65

def calculate_all_attributes(identity)
  entry = @directory.fetch(identity[@directory.index[0]])
  @translator.get_identity(entry)
end

#calculate_attributes(identity, role) ⇒ Hash

Returns A hash of attributes.

Parameters:

  • identity (Hash)
  • role (String)

Returns:

  • (Hash)

    A hash of attributes



55
56
57
58
59
60
# File 'lib/soar/registry/identity/provider/staff/base.rb', line 55

def calculate_attributes(identity, role)
  entry = @directory.fetch(identity[@directory.index[0]])
  return nil if not entry
  identity = @translator.get_identity(entry)
  { role => identity['roles'][role] }
end

#calculate_identifiers(identity) ⇒ Array

Returns list of identifiers.

Parameters:

  • identity (Hash)

Returns:

  • (Array)

    list of identifiers



40
41
42
43
44
45
46
47
48
49
# File 'lib/soar/registry/identity/provider/staff/base.rb', line 40

def calculate_identifiers(identity)
  indexes = @directory.index
  entry = @directory.fetch(identity[@directory.index[0]])
  identity = @translator.get_identity(entry)
  identifiers = []
  indexes.each { |index| 
    identifiers << identity[index]
  }
  identifiers
end

#calculate_roles(identity) ⇒ Array

Returns list of roles.

Parameters:

  • identity (Hash)

Returns:

  • (Array)

    list of roles



25
26
27
28
29
30
31
32
33
34
# File 'lib/soar/registry/identity/provider/staff/base.rb', line 25

def calculate_roles(identity)
  entry = @directory.fetch(identity[@directory.index[0]])
  return nil if not entry
  identity = @translator.get_identity(entry)
  roles = []
  identity['roles'].each do |role, attributes|
    roles << role
  end
  roles
end