Class: Brainstem::ApiDocs::Formatters::OpenApiSpecification::Version2::TagsFormatter

Inherits:
AbstractFormatter
  • Object
show all
Includes:
Helper
Defined in:
lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#format_description, #format_http_method, #format_tag_name, #presenter_title, #type_and_format, #uncapitalize

Methods inherited from AbstractFormatter

call

Constructor Details

#initialize(controllers, options = {}) ⇒ TagsFormatter

Returns a new instance of TagsFormatter.



26
27
28
29
30
31
32
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb', line 26

def initialize(controllers, options = {})
  self.output         = ActiveSupport::HashWithIndifferentAccess.new
  self.controllers    = controllers
  self.ignore_tagging = false

  super options
end

Instance Attribute Details

#controllersObject

Returns the value of attribute controllers.



22
23
24
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb', line 22

def controllers
  @controllers
end

#ignore_taggingObject

Returns the value of attribute ignore_tagging.



22
23
24
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb', line 22

def ignore_tagging
  @ignore_tagging
end

#outputObject

Returns the value of attribute output.



22
23
24
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb', line 22

def output
  @output
end

Instance Method Details

#callObject



34
35
36
37
38
39
40
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb', line 34

def call
  return {} if ignore_tagging || controllers.blank?

  format_tags!
  format_tag_groups!
  output
end

#valid_optionsObject

Declares the options that are permissable to set on this instance.



15
16
17
18
19
20
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb', line 15

def valid_options
  super | [
    :controllers,
    :ignore_tagging
  ]
end