Module: Melitta::Bridges::Base::ClassMethods

Defined in:
lib/melitta/bridges/base.rb

Instance Method Summary collapse

Instance Method Details

#filter(field, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/melitta/bridges/base.rb', line 11

def filter field, &block
  filter = Melitta::FilterDsl.evaluate(Melitta::Filters::Tree, &block)
  class_variable_set("@@#{field}_filter", filter)

  define_method :"#{field}_filter" do |params|
    filter.run(params.fetch(field, {}))
  end
end