Class: Relax2::FluentArg

Inherits:
Object
  • Object
show all
Defined in:
lib/relax2/fluent_arg.rb

Defined Under Namespace

Classes: NameValuePair, ParseResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ FluentArg

Returns a new instance of FluentArg.

Parameters:

  • args (Array<String>)
    ‘GET’, ‘/search’, ‘q=dart’, ‘Authorization:’ ‘Basic’ ‘aXdha2k6MTIzNDUK’


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/relax2/fluent_arg.rb', line 20

def initialize(args)
  maybe_http_method, maybe_path_with_query, *maybe_args = args
  @http_method = validated_http_method_for(maybe_http_method)
  path_with_query = validated_path_for(maybe_path_with_query)
  params_and_headers = parse_params_and_headers_from(maybe_args)

  # Merge query parameters
  uri = URI.parse(path_with_query)
  @query_parameters = query_parameters_from(uri) + params_and_headers.query_parameters
  @path = uri.path
  @headers = params_and_headers.headers
  @magic_parameters = validated_magic_parameters_from(params_and_headers.magic_parameters)
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



34
35
36
# File 'lib/relax2/fluent_arg.rb', line 34

def headers
  @headers
end

#http_methodObject (readonly)

Returns the value of attribute http_method.



34
35
36
# File 'lib/relax2/fluent_arg.rb', line 34

def http_method
  @http_method
end

#magic_parametersObject (readonly)

Returns the value of attribute magic_parameters.



34
35
36
# File 'lib/relax2/fluent_arg.rb', line 34

def magic_parameters
  @magic_parameters
end

#pathObject (readonly)

Returns the value of attribute path.



34
35
36
# File 'lib/relax2/fluent_arg.rb', line 34

def path
  @path
end

#query_parametersObject (readonly)

Returns the value of attribute query_parameters.



34
35
36
# File 'lib/relax2/fluent_arg.rb', line 34

def query_parameters
  @query_parameters
end