Class: RoutingFilter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/routing_filter/base.rb

Direct Known Subclasses

ForceExtension, Locale, Pagination

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/routing_filter/base.rb', line 8

def initialize(options = {})
  @options = options
  options.each { |name, value| instance_variable_set :"@#{name}", value }
end

Instance Attribute Details

#chainObject

Returns the value of attribute chain.



6
7
8
# File 'lib/routing_filter/base.rb', line 6

def chain
  @chain
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/routing_filter/base.rb', line 6

def options
  @options
end

Instance Method Details

#predecessorObject



23
24
25
# File 'lib/routing_filter/base.rb', line 23

def predecessor
  @chain.predecessor(self)
end

#run(method, *args, &block) ⇒ Object



13
14
15
16
# File 'lib/routing_filter/base.rb', line 13

def run(method, *args, &block)
  _next = successor ? lambda { successor.run(method, *args, &block) } : block
  active ? send(method, *args, &_next) : _next.call(*args)
end

#run_reverse(method, *args, &block) ⇒ Object



18
19
20
21
# File 'lib/routing_filter/base.rb', line 18

def run_reverse(method, *args, &block)
  _prev = predecessor ? lambda { predecessor.run(method, *args, &block) } : block
  active ? send(method, *args, &_prev) : _prev.call(*args)
end

#successorObject



27
28
29
# File 'lib/routing_filter/base.rb', line 27

def successor
  @chain.successor(self)
end