Class: Mutx::Support::QueryString

Inherits:
Object
  • Object
show all
Defined in:
lib/mutx/support/query_string.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(req) ⇒ QueryString

req = Request



9
10
11
12
# File 'lib/mutx/support/query_string.rb', line 9

def initialize req
  @req = req
  @values = Rack::Utils.parse_nested_query(req.query_string.split("/").last)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, *args, &block) ⇒ Object



23
24
25
# File 'lib/mutx/support/query_string.rb', line 23

def method_missing(key, *args, &block)
  @values[key.to_s]
end

Instance Attribute Details

#reqObject (readonly)

Returns the value of attribute req.



6
7
8
# File 'lib/mutx/support/query_string.rb', line 6

def req
  @req
end

#valuesObject (readonly)

Returns the value of attribute values.



6
7
8
# File 'lib/mutx/support/query_string.rb', line 6

def values
  @values
end

Instance Method Details

#rawObject



14
15
16
17
# File 'lib/mutx/support/query_string.rb', line 14

def raw
  return nil if @values.empty?
  @values.keys.first
end

#value_for(key) ⇒ Object



19
20
21
# File 'lib/mutx/support/query_string.rb', line 19

def value_for key
  @values[key]
end