Class: Mutx::Support::QueryString
- Inherits:
-
Object
- Object
- Mutx::Support::QueryString
- Defined in:
- lib/mutx/support/query_string.rb
Instance Attribute Summary collapse
-
#req ⇒ Object
readonly
Returns the value of attribute req.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(req) ⇒ QueryString
constructor
req = Request.
- #method_missing(key, *args, &block) ⇒ Object
- #raw ⇒ Object
- #value_for(key) ⇒ Object
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
#req ⇒ Object (readonly)
Returns the value of attribute req.
6 7 8 |
# File 'lib/mutx/support/query_string.rb', line 6 def req @req end |
#values ⇒ Object (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
#raw ⇒ Object
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 |