Class: Sucker::Parameters
- Inherits:
-
Object
- Object
- Sucker::Parameters
- Extended by:
- Forwardable
- Defined in:
- lib/sucker/parameters.rb
Constant Summary collapse
- CURRENT_API_VERSION =
'2011-08-01'
Instance Method Summary collapse
-
#initialize ⇒ Parameters
constructor
A new instance of Parameters.
-
#normalize ⇒ Object
Returns a normalized parameters hash.
-
#reset ⇒ Object
Creates a new hash to store parameters in.
Constructor Details
#initialize ⇒ Parameters
Returns a new instance of Parameters.
11 12 13 |
# File 'lib/sucker/parameters.rb', line 11 def initialize reset end |
Instance Method Details
#normalize ⇒ Object
Returns a normalized parameters hash.
Ensures all keys and values are strings and camelizes former.
26 27 28 29 30 31 32 33 34 |
# File 'lib/sucker/parameters.rb', line 26 def normalize @parameters.inject({}) do |hash, (k, v)| v = v.is_a?(Array) ? v.join(',') : v.to_s k = k.to_s.split('_').map {|w| w[0, 1] = w[0, 1].upcase; w }.join hash[k] = v hash end end |
#reset ⇒ Object
Creates a new hash to store parameters in.
16 17 18 19 20 21 |
# File 'lib/sucker/parameters.rb', line 16 def reset @parameters = { 'Service' => 'AWSECommerceService', 'Version' => CURRENT_API_VERSION, 'Timestamp' => } end |