Module: Poncho::Filters::ClassMethods

Defined in:
lib/poncho/filters.rb

Instance Method Summary collapse

Instance Method Details

#add_filter(type, options = {}, &block) ⇒ Object



38
39
40
# File 'lib/poncho/filters.rb', line 38

def add_filter(type, options = {}, &block)
  filters[type] << Filter.new(options, &block)
end

#filtersObject



34
35
36
# File 'lib/poncho/filters.rb', line 34

def filters
  @filters ||= Hash.new {[]}
end

#run_filters(type, binding = self) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/poncho/filters.rb', line 42

def run_filters(type, binding = self)
  base = self

  while base.respond_to?(:filters)
    base.filters[type].each {|f| binding.instance_eval(&f) }
    base = base.superclass
  end
end