Sha256: 32fc1b85aef6264078eb8d49a6d02c8e404c46375d60f952d675c1d988ba5390
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
require 'forwardable' module Sucker class Parameters extend Forwardable CURRENT_API_VERSION = '2011-08-01' def_delegators :@parameters, :[], :[]=, :merge! def initialize reset end # Creates a new hash to store parameters in. def reset @parameters = { 'Service' => 'AWSECommerceService', 'Version' => CURRENT_API_VERSION, 'Timestamp' => timestamp } end # Returns a normalized parameters hash. # # Ensures all keys and values are strings and camelizes former. 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 private def timestamp Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sucker-2.1.0 | lib/sucker/parameters.rb |