Class: Swagger::Grape::RoutePath

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-swagger/grape/route_path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route_name) ⇒ RoutePath

Returns a new instance of RoutePath.



9
10
11
12
13
14
# File 'lib/ruby-swagger/grape/route_path.rb', line 9

def initialize(route_name)
  @name = route_name
  @operations = {}
  @types = []
  @scopes = []
end

Instance Attribute Details

#scopesObject (readonly)

Returns the value of attribute scopes.



7
8
9
# File 'lib/ruby-swagger/grape/route_path.rb', line 7

def scopes
  @scopes
end

#typesObject (readonly)

Returns the value of attribute types.



7
8
9
# File 'lib/ruby-swagger/grape/route_path.rb', line 7

def types
  @types
end

Instance Method Details

#add_operation(route) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/ruby-swagger/grape/route_path.rb', line 16

def add_operation(route)
  method = Swagger::Grape::Method.new(@name, route)
  grape_operation = method.operation

  @types = (@types | method.types).uniq
  @scopes = (@scopes | method.scopes).uniq
  @operations[route.route_method.downcase] = grape_operation
end

#to_swaggerObject



25
26
27
28
29
30
31
32
33
# File 'lib/ruby-swagger/grape/route_path.rb', line 25

def to_swagger
  path = Swagger::Data::Path.new

  @operations.each do |operation_verb, operation|
    path.send("#{operation_verb}=", operation)
  end

  path
end