Class: Aws::Paging::Pager Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/paging/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.

Direct Known Subclasses

NullPager

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rules) ⇒ 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.



5
6
7
8
9
10
11
12
13
# File 'lib/aws-sdk-core/paging/pager.rb', line 5

def initialize(rules)
  if rules['more_results']
    @more_results = underscore(rules['more_results'])
  end
  if rules['limit_key']
    @limit_key = underscore(rules['limit_key']).to_sym
  end
  map_tokens(rules)
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)


16
17
18
# File 'lib/aws-sdk-core/paging/pager.rb', line 16

def limit_key
  @limit_key
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)


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

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.



28
29
30
31
32
33
# File 'lib/aws-sdk-core/paging/pager.rb', line 28

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)


37
38
39
40
41
42
43
44
45
# File 'lib/aws-sdk-core/paging/pager.rb', line 37

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