Class: GrapeDocumenter::RouteDoc
- Inherits:
-
Object
- Object
- GrapeDocumenter::RouteDoc
- Includes:
- ActiveSupport::Inflector
- Defined in:
- lib/grape_documenter/route_doc.rb
Overview
Route Doc
Instance Method Summary collapse
- #description ⇒ Object
- #http_method ⇒ Object
- #inferred_rails_action ⇒ Object
- #inferred_title ⇒ Object
-
#initialize(route, options = {}) ⇒ RouteDoc
constructor
A new instance of RouteDoc.
- #optional_params ⇒ Object
- #params ⇒ Object
- #path ⇒ Object
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, = {}) @route = route @mounted_path = [:mounted_path] || '' end |
Instance Method Details
#description ⇒ Object
20 21 22 |
# File 'lib/grape_documenter/route_doc.rb', line 20 def description @route.route_description end |
#http_method ⇒ Object
12 13 14 |
# File 'lib/grape_documenter/route_doc.rb', line 12 def http_method @route.route_method end |
#inferred_rails_action ⇒ Object
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_title ⇒ Object
32 33 34 |
# File 'lib/grape_documenter/route_doc.rb', line 32 def inferred_title "To #{inferred_action} #{inferred_resource}" end |
#optional_params ⇒ Object
28 29 30 |
# File 'lib/grape_documenter/route_doc.rb', line 28 def optional_params @route.route_optional_params end |
#params ⇒ Object
24 25 26 |
# File 'lib/grape_documenter/route_doc.rb', line 24 def params @route.route_params end |
#path ⇒ Object
16 17 18 |
# File 'lib/grape_documenter/route_doc.rb', line 16 def path @mounted_path + path_without_format end |