Class: Aws::Resources::Documenter::ResourceOperationDocumenter

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

Instance Attribute Summary collapse

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

#method_object

Constructor Details

#initialize(*args) ⇒ ResourceOperationDocumenter

Returns a new instance of ResourceOperationDocumenter.



6
7
8
9
# File 'lib/aws-sdk-resources/documenter/resource_operation_documenter.rb', line 6

def initialize(*args)
  super
  @plural = @operation.builder.plural?
end

Instance Attribute Details

#pluralBoolean (readonly) Also known as: plural?

Returns ‘true` if this operation returns an array of resource objects. Returns `false` if this method returns a single resource object.

Returns:

  • (Boolean)

    Returns ‘true` if this operation returns an array of resource objects. Returns `false` if this method returns a single resource object.



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

def plural
  @plural
end

Instance Method Details

#example_tagsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/aws-sdk-resources/documenter/resource_operation_documenter.rb', line 26

def example_tags
  id = target_resource_class.identifiers.last.to_s
  idv = target_resource_class_name.downcase + '-' + id.gsub('_', '-')
  example = []
  example << "@example Basic usage"
  example << "  #{resp_variable} = #{variable_name}.#{operation_name}(options)"
  if plural?
    example << "  #{resp_variable}.map(&:#{id})"
    example << "  #=> [#{idv.inspect}, ...]"
  else
    example << "  #{resp_variable}.#{id}"
    example << "  #=> #{idv.inspect}"
  end
  super + [tag(example.join("\n"))]
end

#resp_variableObject



42
43
44
45
46
47
48
# File 'lib/aws-sdk-resources/documenter/resource_operation_documenter.rb', line 42

def resp_variable
  if plural?
    target_resource_class_name.downcase + 's'
  else
    target_resource_class_name.downcase
  end
end

#return_tagObject



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

def return_tag
  if plural?
    tag("@return [Array<#{target_resource_class_name}>]")
  else
    tag("@return [#{target_resource_class_name}]")
  end
end