Class: Grape::Route

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

Overview

A compiled route for inspection.

Instance Method Summary (collapse)

Constructor Details

- (Route) initialize(options = {})

Returns a new instance of Route



4
5
6
# File 'lib/grape/route.rb', line 4

def initialize(options = {})
  @options = options || {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method_id, *arguments)



8
9
10
11
12
13
14
15
# File 'lib/grape/route.rb', line 8

def method_missing(method_id, *arguments)
  match = /route_([_a-zA-Z]\w*)/.match(method_id.to_s)
  if match
    @options[match.captures.last.to_sym]
  else
    super
  end
end

Instance Method Details

- (Object) to_s



17
18
19
# File 'lib/grape/route.rb', line 17

def to_s
  "version=#{route_version}, method=#{route_method}, path=#{route_path}"
end