Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/s3/extensions.rb

Overview

:stopdoc:

Instance Method Summary collapse

Instance Method Details

#to_normalized_optionsObject



13
14
15
16
17
18
19
# File 'lib/aws/s3/extensions.rb', line 13

def to_normalized_options
  # Convert all option names to downcased strings, and replace underscores with hyphens
  inject({}) do |normalized_options, (name, value)|
    normalized_options[name.to_header] = value.to_s
    normalized_options
  end
end

#to_normalized_options!Object



21
22
23
# File 'lib/aws/s3/extensions.rb', line 21

def to_normalized_options!
  replace(to_normalized_options)
end

#to_query_string(include_question_mark = true) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/aws/s3/extensions.rb', line 4

def to_query_string(include_question_mark = true)
  return '' if empty?
  query_string = ''
  query_string << '?' if include_question_mark
  query_string << inject([]) do |parameters, (key, value)|
    parameters << [key, value].map {|element| CGI.escape(element.to_s)}.join('=')
  end.join('&')
end