Class: Hobby::Router::Route

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verb, path, &action) ⇒ Route

Returns a new instance of Route.



3
4
5
6
# File 'lib/hobby/router/route.rb', line 3

def initialize verb, path, &action
  @verb, @path, @action = verb, path, action
  @params = {}
end

Instance Attribute Details

#actionObject Also known as: to_proc

Returns the value of attribute action.



9
10
11
# File 'lib/hobby/router/route.rb', line 9

def action
  @action
end

#paramsObject

Returns the value of attribute params.



9
10
11
# File 'lib/hobby/router/route.rb', line 9

def params
  @params
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#verbObject (readonly)

Returns the value of attribute verb.



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

def verb
  @verb
end

Instance Method Details

#with_params(params) ⇒ Object



11
12
13
14
15
# File 'lib/hobby/router/route.rb', line 11

def with_params params
  new_route = dup
  new_route.params = params
  new_route
end