class GrapeApiary::Route

Public Instance Methods

description() click to toggle source
# File lib/grape-apiary/route.rb, line 20
def description
  "#{__getobj__.description} [#{request_method.upcase}]"
end
list?() click to toggle source
# File lib/grape-apiary/route.rb, line 46
def list?
  %w(GET POST).include?(request_method) && !path.include?(':id')
end
params() click to toggle source
# File lib/grape-apiary/route.rb, line 7
def params
  @params ||= begin
    __getobj__.params.stringify_keys.sort.map do |param|
      Parameter.new(self, *param)
    end
  end
end
path_without_format() click to toggle source
# File lib/grape-apiary/route.rb, line 24
def path_without_format
  path.gsub(/\((.*?)\)/, '')
end
request_description() click to toggle source
# File lib/grape-apiary/route.rb, line 36
def request_description
  "+ Request #{'(application/json)' if request_body?}"
end
response_description() click to toggle source
# File lib/grape-apiary/route.rb, line 40
def response_description
  code = request_method == 'POST' ? 201 : 200

  "+ Response #{code} (application/json)"
end
route_model() click to toggle source
# File lib/grape-apiary/route.rb, line 28
def route_model
  namespace.split('/').last.singularize
end
route_name() click to toggle source
# File lib/grape-apiary/route.rb, line 15
def route_name
  namespace.split('/').last ||
    path.match('\/(\w*?)[\.\/\(]').captures.first
end
route_type() click to toggle source
# File lib/grape-apiary/route.rb, line 32
def route_type
  list? ? 'collection' : 'single'
end

Private Instance Methods

request_body?() click to toggle source
# File lib/grape-apiary/route.rb, line 52
def request_body?
  !%w(GET DELETE).include?(request_method)
end