Class: RoutingFilter::Chain

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

Instance Method Summary collapse

Instance Method Details

#<<(filter) ⇒ Object



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

def << (filter)
  filter.chain = self
  super
end

#predecessor(filter) ⇒ Object



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

def predecessor(filter)
  ix = index(filter)
  ix > 0 ? self[ix - 1] : nil
end

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



11
12
13
# File 'lib/routing_filter.rb', line 11

def run(method, *args, &final)
  RoutingFilter.active && !first.nil? ? first.run(method, *args, &final) : final.call
end

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



15
16
17
# File 'lib/routing_filter.rb', line 15

def run_reverse(method, *args, &final)
  RoutingFilter.active && !last.nil? ? last.run_reverse(method, *args, &final) : final.call
end

#successor(filter) ⇒ Object



24
25
26
27
# File 'lib/routing_filter.rb', line 24

def successor(filter)
  ix = index(filter)
  ix < length - 1 ? self[ix + 1] : nil
end