Class: Alchemrest::UrlBuilder::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/alchemrest/url_builder/options.rb

Constant Summary collapse

InvalidEncoderError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#queryObject

Returns the value of attribute query.



7
8
9
# File 'lib/alchemrest/url_builder/options.rb', line 7

def query
  @query
end

#query_param_encoderObject (readonly)

Returns the value of attribute query_param_encoder.



9
10
11
# File 'lib/alchemrest/url_builder/options.rb', line 9

def query_param_encoder
  @query_param_encoder
end

#valuesObject

Returns the value of attribute values.



7
8
9
# File 'lib/alchemrest/url_builder/options.rb', line 7

def values
  @values
end

Instance Method Details

#create_builder(template:) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/alchemrest/url_builder/options.rb', line 23

def create_builder(template:)
  UrlBuilder.new(
    template:,
    query: query,
    values: values,
    query_param_encoder: query_param_encoder,
  )
end

#encode_query_withObject



19
20
21
# File 'lib/alchemrest/url_builder/options.rb', line 19

def encode_query_with(&)
  @query_param_encoder = Encoders::Custom.new(&)
end

#encode_query_with=(name) ⇒ Object



13
14
15
16
17
# File 'lib/alchemrest/url_builder/options.rb', line 13

def encode_query_with=(name)
  @query_param_encoder = Encoders.find(name)
rescue NoMatchingPatternError
  raise InvalidEncoderError, ":#{name} is not a known query string encoder type. Known types are :rack and :form"
end