Module: Rlyeh::Filters::ClassMethods

Defined in:
lib/rlyeh/filters.rb

Instance Method Summary collapse

Instance Method Details

#define_filters(*names, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rlyeh/filters.rb', line 10

def define_filters(*names, &block)
  names.each do |name|
    unless method_defined?("#{name}_with_filters")
      define_method(:"#{name}_with_filters") do |*args, &block|
        run_filters name, *args do
          send(:"#{name}_without_filters", *args, &block)
        end
      end
      alias_method :"#{name}_without_filters", :"#{name}"
      alias_method :"#{name}", :"#{name}_with_filters"
    end
  end
end