Class: Swaggable::QueryParams
- Inherits:
-
Delegator
- Object
- Delegator
- Swaggable::QueryParams
- Defined in:
- lib/swaggable/query_params.rb
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
- #__getobj__ ⇒ Object
- #hash ⇒ Object
- #hash=(value) ⇒ Object
-
#initialize(arg = nil) ⇒ QueryParams
constructor
A new instance of QueryParams.
- #string ⇒ Object
- #string=(value) ⇒ Object
Constructor Details
#initialize(arg = nil) ⇒ QueryParams
Returns a new instance of QueryParams.
3 4 5 6 7 8 9 10 |
# File 'lib/swaggable/query_params.rb', line 3 def initialize arg = nil case arg when String then self.string = arg when Hash then self.hash = arg when NilClass then self.hash = {} else raise("#{arg.inspect} not supported. Use Hash or String") end end |
Instance Method Details
#[]=(key, value) ⇒ Object
32 33 34 |
# File 'lib/swaggable/query_params.rb', line 32 def []= key, value self.hash= hash.merge(key => value) end |
#__getobj__ ⇒ Object
12 13 14 |
# File 'lib/swaggable/query_params.rb', line 12 def __getobj__ string && hash end |
#hash ⇒ Object
20 21 22 |
# File 'lib/swaggable/query_params.rb', line 20 def hash parse(string).freeze end |
#hash=(value) ⇒ Object
28 29 30 |
# File 'lib/swaggable/query_params.rb', line 28 def hash= value self.string = serialize(value) end |
#string ⇒ Object
16 17 18 |
# File 'lib/swaggable/query_params.rb', line 16 def string @string end |
#string=(value) ⇒ Object
24 25 26 |
# File 'lib/swaggable/query_params.rb', line 24 def string= value @string = value end |