Class: Foobara::CommandConnector::Authenticator

Inherits:
Value::Transformer show all
Defined in:
foobara-0.0.130/projects/command_connectors/src/authenticator.rb

Overview

TODO: should switch to a processor and give errors if the authenticator header is malformed

Instance Attribute Summary collapse

Attributes inherited from Value::Processor

#created_in_namespace, #declaration_data, #parent_declaration_data

Instance Method Summary collapse

Methods inherited from Value::Transformer

create, error_classes, foobara_manifest, #process_value, subclass

Methods inherited from Value::Processor

#always_applicable?, #applicable?, #attribute_name, #build_error, default_declaration_data, #dup_processor, error_class, error_classes, #error_context, #error_message, #error_path, foobara_manifest, #foobara_manifest, #inspect, instance, #method_missing, #name, new_with_agnostic_args, #possible_errors, #priority, #process_outcome, #process_outcome!, #process_value, #process_value!, processor_name, requires_declaration_data?, requires_parent_declaration_data?, #respond_to_missing?, #runner, symbol

Methods included from IsManifestable

#foobara_domain, #foobara_manifest, #foobara_organization, #scoped_clear_caches

Methods included from Foobara::Concern

foobara_class_methods_module_for, foobara_concern?, included

Constructor Details

#initialize(symbol: nil, explanation: nil, &block) ⇒ Authenticator

Returns a new instance of Authenticator.



7
8
9
10
11
12
13
14
# File 'foobara-0.0.130/projects/command_connectors/src/authenticator.rb', line 7

def initialize(symbol: nil, explanation: nil, &block)
  symbol ||= Util.non_full_name_underscore(self.class).to_sym
  explanation ||= symbol

  super(symbol:, explanation:)

  @block = block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Foobara::Value::Processor

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



5
6
7
# File 'foobara-0.0.130/projects/command_connectors/src/authenticator.rb', line 5

def block
  @block
end

Instance Method Details

#authenticate(request) ⇒ Object



32
33
34
35
36
# File 'foobara-0.0.130/projects/command_connectors/src/authenticator.rb', line 32

def authenticate(request)
  if applicable?(request)
    process_value!(request)
  end
end

#explanationObject



24
25
26
# File 'foobara-0.0.130/projects/command_connectors/src/authenticator.rb', line 24

def explanation
  declaration_data[:explanation]
end

#relevant_entity_classes(_request) ⇒ Object



16
17
18
# File 'foobara-0.0.130/projects/command_connectors/src/authenticator.rb', line 16

def relevant_entity_classes(_request)
  nil
end

#symbolObject



20
21
22
# File 'foobara-0.0.130/projects/command_connectors/src/authenticator.rb', line 20

def symbol
  declaration_data[:symbol]
end

#to_procObject



38
39
40
# File 'foobara-0.0.130/projects/command_connectors/src/authenticator.rb', line 38

def to_proc
  block
end

#transform(request) ⇒ Object



28
29
30
# File 'foobara-0.0.130/projects/command_connectors/src/authenticator.rb', line 28

def transform(request)
  request.instance_exec(&to_proc)
end