Module: FilterChain

Included in:
Wakame::Trigger
Defined in:
lib/wakame/util.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



432
433
434
435
436
437
438
439
440
441
442
# File 'lib/wakame/util.rb', line 432

def self.included(klass)
  klass.class_eval {
    def self.filter_chain
      @filter_chain ||= []
    end
    
    def self.append_filter(&blk)
      self.filter_chain << blk
    end
  }
end

Instance Method Details

#run_filter(pass_obj = nil) ⇒ Object



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/wakame/util.rb', line 444

def run_filter(pass_obj=nil)
  retrieve_filter_chain { |filter_chain|
    filter_chain.each { |filter_proc|
      begin
        ret = filter_proc.call(pass_obj)
      rescue => e
        ret = false
      end

      unless ret
        raise 
      end
    }
  }
end