Class: Espago::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/espago/router.rb

Constant Summary collapse

NoPathError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, method) ⇒ Router

Returns a new instance of Router.



8
9
10
# File 'lib/espago/router.rb', line 8

def initialize(path, method)
  @path, @method = path, method
end

Instance Attribute Details

#methodObject

Returns the value of attribute method.



5
6
7
# File 'lib/espago/router.rb', line 5

def method
  @method
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/espago/router.rb', line 5

def path
  @path
end

Instance Method Details

#path_exists?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
# File 'lib/espago/router.rb', line 17

def path_exists?
  get_route
  true
rescue
  false
end

#routeObject

Raises:



12
13
14
15
# File 'lib/espago/router.rb', line 12

def route
  raise NoPathError unless path_exists?
  get_route
end