Class: GrapeDocumenter::RouteDoc

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Inflector
Defined in:
lib/grape_documenter/route_doc.rb

Overview

Route Doc

Instance Method Summary collapse

Constructor Details

#initialize(route, options = {}) ⇒ RouteDoc

Returns a new instance of RouteDoc.



7
8
9
10
# File 'lib/grape_documenter/route_doc.rb', line 7

def initialize(route, options = {})
  @route = route
  @mounted_path = options[:mounted_path] || ''
end

Instance Method Details

#descriptionObject



20
21
22
# File 'lib/grape_documenter/route_doc.rb', line 20

def description
  @route.route_description
end

#http_methodObject



12
13
14
# File 'lib/grape_documenter/route_doc.rb', line 12

def http_method
  @route.route_method
end

#inferred_rails_actionObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/grape_documenter/route_doc.rb', line 36

def inferred_rails_action
  case http_method
  when 'GET'
    inferred_singular? ? 'show' : 'index'
  when 'PUT'
    'update'
  when 'POST'
    'create'
  when 'DELETE'
    'destroy'
  end
end

#inferred_titleObject



32
33
34
# File 'lib/grape_documenter/route_doc.rb', line 32

def inferred_title
  "To #{inferred_action} #{inferred_resource}"
end

#optional_paramsObject



28
29
30
# File 'lib/grape_documenter/route_doc.rb', line 28

def optional_params
  @route.route_optional_params
end

#paramsObject



24
25
26
# File 'lib/grape_documenter/route_doc.rb', line 24

def params
  @route.route_params
end

#pathObject



16
17
18
# File 'lib/grape_documenter/route_doc.rb', line 16

def path
  @mounted_path + path_without_format
end