Class: GrapeMarkdown::Route
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- GrapeMarkdown::Route
- Defined in:
- lib/grape-markdown/route.rb
Instance Method Summary collapse
- #list? ⇒ Boolean
- #route_binding ⇒ Object
- #route_model ⇒ Object
- #route_name ⇒ Object
- #route_params ⇒ Object
- #route_path_without_format ⇒ Object
- #route_short_description ⇒ Object
- #route_type ⇒ Object
Instance Method Details
#list? ⇒ Boolean
38 39 40 |
# File 'lib/grape-markdown/route.rb', line 38 def list? %w(GET POST).include?(route_method) && !route_path.include?(':id') end |
#route_binding ⇒ Object
42 43 44 |
# File 'lib/grape-markdown/route.rb', line 42 def route_binding binding end |
#route_model ⇒ Object
30 31 32 |
# File 'lib/grape-markdown/route.rb', line 30 def route_model route_namespace.split('/').last.singularize end |
#route_name ⇒ Object
17 18 19 20 |
# File 'lib/grape-markdown/route.rb', line 17 def route_name route_namespace.split('/').last || route_path.match('\/(\w*?)[\.\/\(]').captures.first end |
#route_params ⇒ Object
11 12 13 14 15 |
# File 'lib/grape-markdown/route.rb', line 11 def route_params @route_params ||= __getobj__.route_params.sort.map do |param| Parameter.new(self, *param) end end |
#route_path_without_format ⇒ Object
26 27 28 |
# File 'lib/grape-markdown/route.rb', line 26 def route_path_without_format route_path.gsub(/\((.*?)\)/, '') end |
#route_short_description ⇒ Object
22 23 24 |
# File 'lib/grape-markdown/route.rb', line 22 def route_short_description "#{route_method.titleize} a #{route_model}" end |
#route_type ⇒ Object
34 35 36 |
# File 'lib/grape-markdown/route.rb', line 34 def route_type list? ? 'collection' : 'single' end |