Class: Foobara::CommandConnectors::Http::MoveAttributeToCookie

Inherits:
ResponseMutator show all
Defined in:
foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.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 ResponseMutator

#result_type_declaration_from

Methods inherited from Value::Mutator

error_classes, foobara_manifest, #process_value

Methods inherited from Value::Processor

#always_applicable?, #build_error, default_declaration_data, #dup_processor, error_class, error_classes, #error_context, #error_message, #error_path, foobara_manifest, #foobara_manifest, #initialize, #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

This class inherits a constructor from Foobara::Value::Processor

Dynamic Method Handling

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

Class Attribute Details

.attribute_nameObject

Returns the value of attribute attribute_name.



6
7
8
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 6

def attribute_name
  @attribute_name
end

Returns the value of attribute cookie_name.



6
7
8
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 6

def cookie_name
  @cookie_name
end

Returns the value of attribute cookie_opts.



6
7
8
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 6

def cookie_opts
  @cookie_opts
end

Instance Attribute Details

#attribute_nameObject



36
37
38
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 36

def attribute_name
  @attribute_name ||= self.class.attribute_name
end


40
41
42
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 40

def cookie_name
  @cookie_name ||= self.class.cookie_name
end


44
45
46
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 44

def cookie_opts
  @cookie_opts ||= self.class.cookie_opts
end

Class Method Details

.for(attribute_name, cookie_name = attribute_name, **cookie_opts) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 8

def for(attribute_name, cookie_name = attribute_name, **cookie_opts)
  subclass = Class.new(self)

  subclass.attribute_name = attribute_name
  subclass.cookie_name = cookie_name
  subclass.cookie_opts = cookie_opts

  subclass
end

Instance Method Details

#applicable?(response) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 27

def applicable?(response)
  response.command.success?
end

#mutate(response) ⇒ Object



31
32
33
34
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 31

def mutate(response)
  cookie_value = response.body.delete(attribute_name)
  response.add_cookie(cookie_name, cookie_value, cookie_opts)
end

#result_type_from(result_type) ⇒ Object



21
22
23
24
25
# File 'foobara-http-command-connector-0.0.23/src/http/response_mutators/move_attribute_to_cookie.rb', line 21

def result_type_from(result_type)
  new_declaration = TypeDeclarations::Attributes.reject(result_type.declaration_data, attribute_name)

  Domain.current.foobara_type_from_declaration(new_declaration)
end