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

Inherits:
BaseOperationDocumenter show all
Defined in:
aws-sdk-resources/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 'aws-sdk-resources/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 'aws-sdk-resources/lib/aws-sdk-resources/documenter/resource_operation_documenter.rb', line 14

def plural
  @plural
end

Instance Method Details

#docstringObject


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

def docstring
  super + ' ' "#{return_message} Calls {#{called_operation}}."
end

#example_tagsObject


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/resource_operation_documenter.rb', line 38

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

#resp_variableObject


54
55
56
57
58
59
60
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/resource_operation_documenter.rb', line 54

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

#return_messageObject


30
31
32
33
34
35
36
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/resource_operation_documenter.rb', line 30

def return_message
  if plural?
    "Returns an array of {#{target_resource_class_name}} resources."
  else
    "Returns a {#{target_resource_class_name}} resource."
  end
end

#return_typeObject


22
23
24
25
26
27
28
# File 'aws-sdk-resources/lib/aws-sdk-resources/documenter/resource_operation_documenter.rb', line 22

def return_type
  if plural?
    ["Array<#{target_resource_class_name}>"]
  else
    [target_resource_class_name]
  end
end