Class: SwaggerDocsGenerator::ParserController

Inherits:
Parser
  • Object
show all
Defined in:
lib/swagger_docs_generator/parser/controller.rb

Overview

# Parse Controller classes

Parse controller classes in Rails application. It’s create temporary file and adding automaticaly tags element.

Instance Attribute Summary

Attributes inherited from Parser

#controller, #tag_name

Instance Method Summary collapse

Methods inherited from Parser

#temporary_file

Constructor Details

#initialize(description) ⇒ ParserController

Returns a new instance of ParserController.



9
10
11
12
13
# File 'lib/swagger_docs_generator/parser/controller.rb', line 9

def initialize(description)
  super(binding.of_callers[1].klass)
  @description = description
  prepare_file
end

Instance Method Details

#adding_tagObject



15
16
17
18
19
20
21
# File 'lib/swagger_docs_generator/parser/controller.rb', line 15

def adding_tag
  json = JSON.parse(File.read(temporary_file))
  File.open(temporary_file, 'w') do |file|
    json['tags'].merge!(construct_tags)
    file.puts(JSON.pretty_generate(json))
  end
end