Class: Fairy::FilterChain

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

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ FilterChain

Returns a new instance of FilterChain.



170
171
172
# File 'lib/fairy.rb', line 170

def initialize(input)
  @filters = [input]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg, *args, &block) ⇒ Object



184
185
186
187
188
189
190
191
192
193
# File 'lib/fairy.rb', line 184

def method_missing(msg, *args, &block)
  #pp msg
  ret = @filters.last.__send__(msg, *args, &block)
  if ret.kind_of?(Job)
    @filters << ret
    self
  else
    ret
  end
end

Instance Method Details

#[](idx) ⇒ Object



174
175
176
# File 'lib/fairy.rb', line 174

def [](idx)
  @filters[idx]
end

#show_chainObject



178
179
180
181
182
# File 'lib/fairy.rb', line 178

def show_chain
  @filters.each_with_index{|f, idx|
    puts "[#{idx}]\t#{f.class}" 
  }
end