Class: Foobara::CommandConnectors::Http::Commands::GetOptions

Inherits:
Foobara::Command
  • Object
show all
Defined in:
foobara-http-command-connector-0.0.23/src/http/commands/get_options.rb

Overview

TODO: this is a bit of a hack, just a total no-op… shouldn’t really need this command at all ideally

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary

Attributes included from Foobara::CommandPatternImplementation::Concerns::Subcommands

#is_subcommand

Attributes included from Foobara::CommandPatternImplementation::Concerns::Runtime

#exception, #outcome

Attributes included from Foobara::CommandPatternImplementation::Concerns::Errors

#error_collection

Attributes included from Foobara::CommandPatternImplementation::Concerns::Inputs

#inputs, #raw_inputs

Instance Method Summary collapse

Methods inherited from Foobara::Command

install!, reset_all

Methods included from Foobara::Concern

foobara_class_methods_module_for, foobara_concern?, included

Methods included from Foobara::CommandPatternImplementation::Concerns::Reflection

#initialize

Methods included from Foobara::CommandPatternImplementation::Concerns::DomainMappers

#domain_map, #domain_map!, #run_mapped_subcommand!

Methods included from Foobara::CommandPatternImplementation::Concerns::Subcommands

#run_subcommand!, #subcommand?

Methods included from Foobara::CommandPatternImplementation::Concerns::Entities

#load_entities, #load_records

Methods included from Foobara::CommandPatternImplementation::Concerns::Transactions

#auto_detect_current_transactions, #commit_transaction, #open_transaction, #opened_transactions, #relevant_entity_classes, #rollback_transaction, #transactions

Methods included from Foobara::CommandPatternImplementation::Concerns::StateMachine

#state_machine

Methods included from Foobara::CommandPatternImplementation::Concerns::Runtime

#halt!, #run, #run!, #run_execute, #succeed, #success?, #validate, #validate_records

Methods included from Foobara::CommandPatternImplementation::Concerns::Errors

#initialize

Methods included from Foobara::CommandPatternImplementation::Concerns::Inputs

#cast_and_validate_inputs, #initialize, #method_missing, #respond_to_missing?, #respond_to_missing_for_inputs?

Methods included from TruncatedInspect

#inspect, truncating

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Foobara::CommandPatternImplementation::Concerns::Inputs

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
# File 'foobara-http-command-connector-0.0.23/src/http/commands/get_options.rb', line 12

def execute
  initialize_response_headers

  set_allow_methods
  set_allow_headers
  set_access_control_max_age

  # TODO: what's with this empty string?
  ""
end

#initialize_response_headersObject



23
24
25
# File 'foobara-http-command-connector-0.0.23/src/http/commands/get_options.rb', line 23

def initialize_response_headers
  request.response_headers ||= {}
end

#set_access_control_max_ageObject



44
45
46
47
48
49
# File 'foobara-http-command-connector-0.0.23/src/http/commands/get_options.rb', line 44

def set_access_control_max_age
  access_control_max_age = ENV.fetch("FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE", nil)
  if access_control_max_age
    request.response_headers["access-control-max-age"] = access_control_max_age
  end
end

#set_allow_headersObject



34
35
36
37
38
39
40
41
42
# File 'foobara-http-command-connector-0.0.23/src/http/commands/get_options.rb', line 34

def set_allow_headers
  allow_headers = ENV.fetch("FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS", nil)
  if allow_headers
    if allow_headers == "*"
      allow_headers = request.headers["access-control-request-headers"]
    end
    request.response_headers["access-control-allow-headers"] = allow_headers
  end
end

#set_allow_methodsObject



27
28
29
30
31
32
# File 'foobara-http-command-connector-0.0.23/src/http/commands/get_options.rb', line 27

def set_allow_methods
  allow_methods = ENV.fetch("FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS", nil)
  if allow_methods
    request.response_headers["access-control-allow-methods"] = allow_methods
  end
end