Class: GrapeMarkdown::Route

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/grape-markdown/route.rb

Instance Method Summary collapse

Instance Method Details

#list?Boolean

Returns:

  • (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_bindingObject



42
43
44
# File 'lib/grape-markdown/route.rb', line 42

def route_binding
  binding
end

#route_modelObject



30
31
32
# File 'lib/grape-markdown/route.rb', line 30

def route_model
  route_namespace.split('/').last.singularize
end

#route_nameObject



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_paramsObject



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_formatObject



26
27
28
# File 'lib/grape-markdown/route.rb', line 26

def route_path_without_format
  route_path.gsub(/\((.*?)\)/, '')
end

#route_short_descriptionObject



22
23
24
# File 'lib/grape-markdown/route.rb', line 22

def route_short_description
  "#{route_method.titleize} a #{route_model}"
end

#route_typeObject



34
35
36
# File 'lib/grape-markdown/route.rb', line 34

def route_type
  list? ? 'collection' : 'single'
end