Class: Aws::Pager Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/pager.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: NullPager

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Pager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Pager.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :tokens (required, Hash<JMESPath,JMESPath>)
  • :limit_key (String<JMESPath>)
  • :more_results (String<JMESPath>)


12
13
14
15
16
# File 'lib/aws-sdk-core/pager.rb', line 12

def initialize(options)
  @tokens = options.fetch(:tokens)
  @limit_key = options.fetch(:limit_key, nil)
  @more_results = options.fetch(:more_results, nil)
end

Instance Attribute Details

#limit_keySymbol? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Symbol, nil)


19
20
21
# File 'lib/aws-sdk-core/pager.rb', line 19

def limit_key
  @limit_key
end

#tokensHash? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash, nil)


22
23
24
# File 'lib/aws-sdk-core/pager.rb', line 22

def tokens
  @tokens
end

Instance Method Details

#next_tokens(response) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (Hash)


26
27
28
29
30
31
# File 'lib/aws-sdk-core/pager.rb', line 26

def next_tokens(response)
  @tokens.each.with_object({}) do |(source, target), next_tokens|
    value = JMESPath.search(source, response.data)
    next_tokens[target.to_sym] = value unless empty_value?(value)
  end
end

#prev_tokens(response) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
37
38
39
# File 'lib/aws-sdk-core/pager.rb', line 34

def prev_tokens(response)
  @tokens.each.with_object({}) do |(_, target), tokens|
    value = JMESPath.search(target, response.context.params)
    tokens[target.to_sym] = value unless empty_value?(value)
  end
end

#truncated?(response) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
51
# File 'lib/aws-sdk-core/pager.rb', line 43

def truncated?(response)
  if @more_results
    JMESPath.search(@more_results, response.data)
  else
    next_t = next_tokens(response)
    prev_t = prev_tokens(response)
    !(next_t.empty? || next_t == prev_t)
  end
end