Class: RoutingFilter::Filter

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

Direct Known Subclasses

Extension, Locale, Pagination, Uuid

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Filter

Returns a new instance of Filter.



5
6
7
# File 'lib/routing_filter/filter.rb', line 5

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#nextObject

Returns the value of attribute next.



3
4
5
# File 'lib/routing_filter/filter.rb', line 3

def next
  @next
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/routing_filter/filter.rb', line 3

def options
  @options
end

#previousObject

Returns the value of attribute previous.



3
4
5
# File 'lib/routing_filter/filter.rb', line 3

def previous
  @previous
end

Instance Method Details

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



9
10
11
12
# File 'lib/routing_filter/filter.rb', line 9

def run(method, *args, &block)
  _next = self.next ? proc {|path, env| self.next.run(method, *args, &block) } : block
  RoutingFilter.active? ? send(method, *args, &_next) : _next.call(*args)
end

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



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

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