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, #path, #version

Instance Method Summary collapse

Methods inherited from Parser

#controller_file

Constructor Details

#initialize(controller, 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(controller, description)
  super(controller)
  prepare_file
  @description = description
end

Instance Method Details

#adding_tagObject



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

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