Class: Foobara::CommandConnector::Authenticator

Inherits:
TypeDeclarations::TypedTransformer show all
Defined in:
foobara-0.5.8/projects/command_connectors/src/authenticator.rb,
foobara-0.5.8/projects/entities_plumbing/src/extensions/authenticator.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from Value::Processor

#created_in_namespace, #declaration_data, #parent_declaration_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TypeDeclarations::TypedTransformer

#always_applicable?, from, #from, #from_type, #from_type_declaration, #has_from_type?, #has_to_type?, #process_value, requires_declaration_data?, requires_parent_declaration_data?, to, #to, #to_type, #to_type_declaration

Methods inherited from Value::Transformer

create, error_classes, foobara_manifest, #process_value

Methods inherited from Value::Processor

#always_applicable?, #applicable?, #attribute_name, #build_error, default_declaration_data, #dup_processor, error_class, #error_class, error_classes, #error_classes, #error_context, #error_message, #error_path, foobara_manifest, #foobara_manifest, #inspect, #method_missing, #name, new_with_agnostic_args, #possible_errors, #priority, #process_outcome, #process_outcome!, #process_value, #process_value!, processor_name, requires_declaration_data?, #requires_declaration_data?, requires_parent_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.



30
31
32
33
34
35
36
37
# File 'projects/command_connectors/src/authenticator.rb', line 30

def initialize(symbol: nil, explanation: nil, &block)
  self.symbol = symbol || self.class.default_symbol
  @explanation = explanation || self.class.default_explanation || self.symbol

  super()

  @block = block || self.class.default_block
end

Dynamic Method Handling

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

Class Attribute Details

.default_blockObject

Returns the value of attribute default_block.



6
7
8
# File 'projects/command_connectors/src/authenticator.rb', line 6

def default_block
  @default_block
end

.default_explanationObject

Returns the value of attribute default_explanation.



6
7
8
# File 'projects/command_connectors/src/authenticator.rb', line 6

def default_explanation
  @default_explanation
end

.default_symbolObject



18
19
20
# File 'projects/command_connectors/src/authenticator.rb', line 18

def default_symbol
  @default_symbol || Util.non_full_name_underscore(self)&.to_sym
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

#explanationObject (readonly)

Returns the value of attribute explanation.



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

def explanation
  @explanation
end

#symbolObject

Returns the value of attribute symbol.



27
28
29
# File 'projects/command_connectors/src/authenticator.rb', line 27

def symbol
  @symbol
end

Class Method Details

.instanceObject



22
23
24
# File 'projects/command_connectors/src/authenticator.rb', line 22

def instance
  @instance ||= new
end

.subclass(to: nil, symbol: nil, explanation: nil, &default_block) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'projects/command_connectors/src/authenticator.rb', line 8

def subclass(to: nil, symbol: nil, explanation: nil, &default_block)
  klass = super(to:, from: Request, &nil)

  klass.default_symbol = symbol if symbol
  klass.default_explanation = explanation if explanation
  klass.default_block = default_block if default_block

  klass
end

Instance Method Details

#authenticate(request) ⇒ Object



43
44
45
46
47
# File 'projects/command_connectors/src/authenticator.rb', line 43

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

#relevant_entity_classes(_request) ⇒ Object



4
5
6
7
8
9
10
# File 'projects/entities_plumbing/src/extensions/authenticator.rb', line 4

def relevant_entity_classes(_request)
  if to_type&.extends?(BuiltinTypes[:entity])
    NestedTransactionable.relevant_entity_classes_for_type(to_type)
  else
    EMPTY_ARRAY
  end
end

#to_procObject



49
50
51
# File 'projects/command_connectors/src/authenticator.rb', line 49

def to_proc
  block
end

#transform(request) ⇒ Object



39
40
41
# File 'projects/command_connectors/src/authenticator.rb', line 39

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