Class: SwaggerDocsGenerator::ParserDefinition
- Defined in:
- lib/swagger_docs_generator/parser/definition.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
Instance Method Summary collapse
- #adding_definition ⇒ Object
-
#initialize(name, &block) ⇒ ParserDefinition
constructor
A new instance of ParserDefinition.
Methods inherited from Parser
Constructor Details
#initialize(name, &block) ⇒ ParserDefinition
Returns a new instance of ParserDefinition.
10 11 12 13 14 |
# File 'lib/swagger_docs_generator/parser/definition.rb', line 10 def initialize(name, &block) super(binding.of_callers[1].klass) @name = name instance_eval(&block) end |
Instance Method Details
#adding_definition ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/swagger_docs_generator/parser/definition.rb', line 16 def adding_definition json = JSON.parse(File.read(temporary_file)) File.open(temporary_file, 'w') do |file| json['definitions'].merge!(construct_definition) file.puts(JSON.pretty_generate(json)) end end |