Class: AwsSdb::Request::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_sdb_bare/request.rb

Overview

Is the parent of all the request templates, defines some methods

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}, opts = {}) ⇒ Template

takes the params for the request and an optional options hash params for the request are request specific, options accepted are only AWS credentials in form of

{:account => 'your account', :secret => 'your secret'}


108
109
110
# File 'lib/aws_sdb_bare/request.rb', line 108

def initialize(params={}, opts={})
  @params, @opts = params, opts
end

Class Method Details

.shortcuts(shortcuts_hash) ⇒ Object

Generates method to allow shorter expressions in parameter definition takes an hash

shortcuts({'LongUrlQueryParams' => :abbr})

will cause :abbr params to be expanded in LongUrlQueryParams



93
94
95
96
97
98
99
# File 'lib/aws_sdb_bare/request.rb', line 93

def shortcuts(shortcuts_hash)
  shortcuts_hash.each do |full_key, shortcut|
    define_method("#{shortcut}=") do |value|
      @params[full_key] = value
    end
  end
end

Instance Method Details

#attributes=(attributes) ⇒ Object



116
117
118
119
120
# File 'lib/aws_sdb_bare/request.rb', line 116

def attributes=(attributes)
  attributes.each_with_index do |attribute, index|
    @params["AttributeName.#{index}"] = attribute.to_s
  end
end

#requestObject



122
123
124
125
126
127
# File 'lib/aws_sdb_bare/request.rb', line 122

def request
  expand!
  @request ||= begin
    Base.new('GET', @params.merge('Action' => self.class.to_s.split(':')[-1]), @opts)
  end
end

#token=(value) ⇒ Object



112
113
114
# File 'lib/aws_sdb_bare/request.rb', line 112

def token=(value)
  @params['NextToken'] = value
end