Class: Sucker::Parameters

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sucker/parameters.rb

Constant Summary collapse

CURRENT_API_VERSION =
'2011-08-01'

Instance Method Summary collapse

Constructor Details

#initializeParameters

Returns a new instance of Parameters.



11
12
13
# File 'lib/sucker/parameters.rb', line 11

def initialize
  reset
end

Instance Method Details

#normalizeObject

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

#resetObject

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' => timestamp }
end