class Soar::Registry::Staff::Directory::Stub

Attributes

connection[W]
interface[RW]
network[W]

Public Class Methods

new() click to toggle source
# File lib/soar/registry/staff/directory/stub.rb, line 18
def initialize
  @interface = Mince::HashyDb::Interface
  @network = true
  @connection = true
end

Public Instance Methods

authenticate(credentials) click to toggle source
# File lib/soar/registry/staff/directory/stub.rb, line 45
def authenticate(credentials)
  raise Soar::Registry::Staff::Directory::Error::AuthenticationError, 'missing username' if not credentials.key?('username')
  raise Soar::Registry::Staff::Directory::Error::AuthenticationError, 'missing password' if not credentials.key?('password')
end
bootstrap(configuration) click to toggle source

@param [Hash] configuration for the directory provider @return [Nil] @raise [Soar::Registry::Staff::Directory::Error::BootstrapError] if required configuration is missing

# File lib/soar/registry/staff/directory/stub.rb, line 29
def bootstrap(configuration)
  @configuration = configuration
  raise Soar::Registry::Staff::Directory::Error::BootstrapError if configuration.empty?
end
bootstrapped?() click to toggle source

@return [Bool] whether directory provider received minimum required configuration

# File lib/soar/registry/staff/directory/stub.rb, line 37
def bootstrapped?
  true
end
connect() click to toggle source
# File lib/soar/registry/staff/directory/stub.rb, line 50
def connect
  raise Soar::Registry::Staff::Directory::Error::ConnectionError if not @connection
  true
end
connected?() click to toggle source
# File lib/soar/registry/staff/directory/stub.rb, line 55
def connected?
  true
end
fetch_identity(identity_id) click to toggle source

@param [String] identity_id primary key of the identity @return [Hash] the identity @raise [Soar::Registry::Staff::Directory::DynamoDb::Error::UniqueIdentifierNotFoundError] if primary key not found

# File lib/soar/registry/staff/directory/stub.rb, line 72
def fetch_identity(identity_id)
  identity = @interface.get_for_key_with_value('identities', "identity_id", identity_id)
  raise Soar::Registry::Staff::Directory::Error::UniqueIdentifierNotFoundError if identity.nil?
  identity
end
indexed_attributes() click to toggle source

@return [Array] a list of primary keys and global secondary indexes

# File lib/soar/registry/staff/directory/stub.rb, line 99
def indexed_attributes
  ["identity_id", "email", "entity_id"]
end
put_identity(entity) click to toggle source
# File lib/soar/registry/staff/directory/stub.rb, line 63
def put_identity(entity)
  @interface.add('identities', entity)
end
ready?() click to toggle source
# File lib/soar/registry/staff/directory/stub.rb, line 59
def ready?
  @network
end
search_identities(identifier_attribute, identifier_value) click to toggle source

@param [String] identifier_attribute @param [String] identifier_value @return [Array] list of identities @raise [ArgumentError] if query or index is not specified

# File lib/soar/registry/staff/directory/stub.rb, line 84
def search_identities(identifier_attribute, identifier_value)
  identities = []
  @interface.find_all('identities').each { |identity| 
    if identity[identifier_attribute] == identifier_value
      identities << identity
    else
      next
    end
  }
  identities
end
uri() click to toggle source
# File lib/soar/registry/staff/directory/stub.rb, line 41
def uri
  @configuration['endpoint']
end