Class: Wayfarer::Routing::Matchers::Custom

Inherits:
Object
  • Object
show all
Includes:
EmptyParams, Stringify
Defined in:
lib/wayfarer/routing/matchers/custom.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EmptyParams

#params

Methods included from Stringify

#to_s

Constructor Details

#initialize(delegate) ⇒ Custom

Returns a new instance of Custom.



12
13
14
# File 'lib/wayfarer/routing/matchers/custom.rb', line 12

def initialize(delegate)
  @delegate = delegate
end

Instance Attribute Details

#delegateObject (readonly)

Returns the value of attribute delegate.



10
11
12
# File 'lib/wayfarer/routing/matchers/custom.rb', line 10

def delegate
  @delegate
end

Instance Method Details

#evaluate(path_finder) ⇒ Object



16
17
18
19
20
# File 'lib/wayfarer/routing/matchers/custom.rb', line 16

def evaluate(path_finder)
  Wayfarer::Routing::RootRoute.new.tap do |route|
    delegate.call(route, path_finder.uri, path_finder.task)
  end
end

#to_hObject



22
23
24
# File 'lib/wayfarer/routing/matchers/custom.rb', line 22

def to_h
  { custom: delegate.class.name }
end