Class: FilterChain::Filter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, &block) ⇒ Filter

Returns a new instance of Filter.



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

def initialize(opts = {}, &block)
  @opts = opts
  @block = block
  on_initialize
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/filter_chain/filter.rb', line 4

def block
  @block
end

#next_filterObject

Returns the value of attribute next_filter.



6
7
8
# File 'lib/filter_chain/filter.rb', line 6

def next_filter
  @next_filter
end

#optsObject (readonly)

Returns the value of attribute opts.



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

def opts
  @opts
end

Instance Method Details

#<<(data) ⇒ Object



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

def <<(data)
  on_input(data)
end

#pass(data) ⇒ Object



18
19
20
# File 'lib/filter_chain/filter.rb', line 18

def pass(data)
  next_filter ? next_filter << data : data
end