class Keycard::Request::AttributesFactory

Factory to simplify creation of Attributes instances. It binds in a list of finders and inspects the Keycard.config.access mode to determine which subclass to use. You can register a factory instance as a service and then use .for instead of naming concrete classes when processing requests.

Constants

MODE_MAP

Attributes

finders[R]

Public Class Methods

new(finders: [Keycard::InstitutionFinder.new]) click to toggle source
# File lib/keycard/request/attributes_factory.rb, line 16
def initialize(finders: [Keycard::InstitutionFinder.new])
  @finders = finders
end

Public Instance Methods

for(request) click to toggle source
# File lib/keycard/request/attributes_factory.rb, line 20
def for(request)
  mode = MODE_MAP[Keycard.config.access.to_sym]
  if mode.nil?
    # TODO: Warn about this once to the appropriate log; probably in a config check, not here.
    # puts "Keycard does not recognize the '#{access}' access mode, using 'direct'."
    mode = DirectAttributes
  end
  mode.new(request, finders: finders)
end