You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::Resources::Documenter::HasManyOperationDocumenter

Inherits:
BaseOperationDocumenter show all
Defined in:
aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb

Instance Attribute Summary

Attributes inherited from BaseOperationDocumenter

#api_request, #api_request_name, #api_request_params, #builder, #called_operation, #operation_name, #resource_class, #resource_class_name, #source, #target_resource_class, #target_resource_class_name, #yard_class

Instance Method Summary collapse

Methods inherited from BaseOperationDocumenter

#initialize, #method_object

Constructor Details

This class inherits a constructor from Aws::Resources::Documenter::BaseOperationDocumenter

Instance Method Details

#batch_examples_tagObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb', line 45

def batch_examples_tag
  example = []
  example << "@example Batch operations callable on the returned collection"
  target_resource_batch_operations.each do |name, operation|
    if operation.respond_to?(:request)
      example << ""
      example << "  # calls Client##{operation.request.method_name} on each batch"
      example << "  #{variable_name}.#{@operation_name}.#{name}"
    end
  end
  tag(example.join("\n"))
end

#docstringObject



6
7
8
9
10
11
12
13
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb', line 6

def docstring
  super + ' ' + <<-DOCSTRING.lstrip
Returns a {Resources::Collection Collection} of {#{target_resource_class_name}}
resources. No API requests are made until you call an enumerable method on the
collection. {#{called_operation}} will be called multiple times until every
{#{target_resource_class_name}} has been yielded.
  DOCSTRING
end

#enumerate_example_tagObject



27
28
29
30
31
32
33
34
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb', line 27

def enumerate_example_tag
  tag(<<-EXAMPLE.strip)
@example Enumerating {#{target_resource_class_name}} resources.
  #{variable_name}.#{@operation_name}.each do |#{target_resource_class_name.downcase}|
    # yields each #{target_resource_class_name.downcase}
  end
  EXAMPLE
end

#enumerate_with_limit_example_tagObject



36
37
38
39
40
41
42
43
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb', line 36

def enumerate_with_limit_example_tag
  tag(<<-EXAMPLE.strip)
@example Enumerating {#{target_resource_class_name}} resources with a limit.
  #{variable_name}.#{@operation_name}.limit(10).each do |#{target_resource_class_name.downcase}|
    # yields at most 10 #{@operation_name}
  end
  EXAMPLE
end

#example_tagsObject



19
20
21
22
23
24
25
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb', line 19

def example_tags
  tags = super
  tags << enumerate_example_tag
  tags << enumerate_with_limit_example_tag
  tags << batch_examples_tag if target_resource_batches?
  tags
end

#return_tagObject



15
16
17
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb', line 15

def return_tag
  tag("@return [Collection<#{target_resource_class_name}>]")
end

#target_resource_batch_operationsObject



62
63
64
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb', line 62

def target_resource_batch_operations
  target_resource_class.batch_operations
end

#target_resource_batches?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb', line 58

def target_resource_batches?
  target_resource_batch_operations.count > 0
end