Class: Dynamoid::AdapterPlugin::AwsSdkV3::ExecuteStatement

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamoid/adapter_plugin/aws_sdk_v3/execute_statement.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, statement, parameters, options) ⇒ ExecuteStatement

Returns a new instance of ExecuteStatement.



23
24
25
26
27
28
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/execute_statement.rb', line 23

def initialize(client, statement, parameters, options)
  @client = client
  @statement = statement
  @parameters = parameters
  @options = options.symbolize_keys.slice(:consistent_read)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



21
22
23
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/execute_statement.rb', line 21

def client
  @client
end

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/execute_statement.rb', line 21

def options
  @options
end

#parametersObject (readonly)

Returns the value of attribute parameters.



21
22
23
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/execute_statement.rb', line 21

def parameters
  @parameters
end

#statementObject (readonly)

Returns the value of attribute statement.



21
22
23
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/execute_statement.rb', line 21

def statement
  @statement
end

Instance Method Details

#callObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/execute_statement.rb', line 30

def call
  request = {
    statement: @statement,
    parameters: @parameters,
    consistent_read: @options[:consistent_read],
  }

  response = client.execute_statement(request)

  unless response.next_token
    return response_to_items(response)
  end

  Enumerator.new do |yielder|
    yielder.yield(response_to_items(response))

    while response.next_token
      request[:next_token] = response.next_token
      response = client.execute_statement(request)
      yielder.yield(response_to_items(response))
    end
  end
end