Class: Signpost::Sign::Flat

Inherits:
Object
  • Object
show all
Defined in:
lib/signpost/sign/flat.rb,
lib/signpost/sign/flat/path.rb,
lib/signpost/sign/flat/redirect.rb

Direct Known Subclasses

Path, Redirect

Defined Under Namespace

Classes: Any, Path, Redirect

Instance Method Summary collapse

Instance Method Details

#capture(constraints) ⇒ Object

Define pattern constraints for the route

Params:

  • constraints Hash|Array|Symbol|RegExp|String

Examples:

get('/:id').capture(:digit)
get('/:id').capture(/\d+/)
get('/:id_or_slug').capture([/\d+/, :word])
get('/:id.:ext').capture(id: /\d+/, ext: ['png', 'jpg'])


35
36
37
38
# File 'lib/signpost/sign/flat.rb', line 35

def capture(constraints)
  @capture = constraints
  self
end

#except(pattern) ⇒ Object

Do not match given pattern

Params:

  • pattern String pattern to ignore

Examples:

delete('/pages/:id').except('/pages/1')
get('/pages/*slug/edit').except('/pages/system/*/edit')


17
18
19
20
# File 'lib/signpost/sign/flat.rb', line 17

def except(pattern)
  @except = pattern
  self
end

#expose(router, routing_table, named_routes) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/signpost/sign/flat.rb', line 40

def expose(router, routing_table, named_routes)
  route = Route::Simple.new(get_matcher, build_stack(router), build_params, @constraints, @name)
  named_routes[route.name.to_sym] = route if route.name

  http_methods.each do |method|
    routing_table[method] << route
  end
end