Class: Swaggard::Parsers::Controllers

Inherits:
Object
  • Object
show all
Defined in:
lib/swaggard/parsers/controllers.rb

Instance Method Summary collapse

Instance Method Details

#run(yard_objects, routes) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/swaggard/parsers/controllers.rb', line 8

def run(yard_objects, routes)
  tag = nil
  operations = []

  yard_objects.each do |yard_object|
    if yard_object.type == :class
      tag = Swagger::Tag.new(yard_object)
    elsif tag && yard_object.type == :method
      operation = Swagger::Operation.new(yard_object, tag, routes)
      operations << operation if operation.valid?
    end
  end

  return unless operations.any?

  return tag, operations
end