Class: Signpost::Sign::Flat::Path
- Inherits:
-
Signpost::Sign::Flat
- Object
- Signpost::Sign::Flat
- Signpost::Sign::Flat::Path
- Defined in:
- lib/signpost/sign/flat/path.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#as(name, postfix = nil) ⇒ Object
Define named route.
-
#constraint(*constraints) ⇒ Object
(also: #constraints)
Define domain constraints for the route.
-
#params(params) ⇒ Object
Define default or additional params.
-
#to(spec = nil, &block) ⇒ Object
Route endpoint specification Might be a string, hash or class wich defines controller and action names.
Methods inherited from Signpost::Sign::Flat
Instance Method Details
#as(name, postfix = nil) ⇒ Object
Define named route
Params:
-
name String|Symbol route name
36 37 38 39 |
# File 'lib/signpost/sign/flat/path.rb', line 36 def as(name, postfix=nil) @name = (postfix ? [name, @namespace, postfix] : [@namespace, name]).flatten.compact.join('_') self end |
#constraint(*constraints) ⇒ Object Also known as: constraints
Define domain constraints for the route
Params:
-
constraints Array
Examples:
get('/stats').constraint(->(env) { env['RACK_ENV'] == 'development' })
51 52 53 54 |
# File 'lib/signpost/sign/flat/path.rb', line 51 def constraint(*constraints) @constraints = constraints self end |
#params(params) ⇒ Object
Define default or additional params
Params:
-
params Hash
Examples:
get('/pages/:id').params(id: 1)
match('/:controller/:action').params(from: :dynamic_route)
68 69 70 71 |
# File 'lib/signpost/sign/flat/path.rb', line 68 def params(params) @params = params self end |
#to(spec = nil, &block) ⇒ Object
Route endpoint specification Might be a string, hash or class wich defines controller and action names. Rack-compatible block is also acceptable.
Params:
-
spec String|Hash|Class|Proc endpoint spec
Examples:
get('/').to('admin/users#index')
get('/').to('Admin::Users#index')
get('/').to(controller: 'Admin::Users', action: 'index')
get('/').to(Admin::Users::List)
get('/').to do |env|
[200, {}, ['Hello world!']]
end
25 26 27 28 |
# File 'lib/signpost/sign/flat/path.rb', line 25 def to(spec=nil, &block) @to = spec || block self end |