module BabySqueel::ActiveRecord::Base

Public Instance Methods

sifter(name, &block) click to toggle source

Define a sifter that can be used within DSL blocks.

Examples

class Post < ActiveRecord::Base
  sifter :name_contains do |string|
    name =~ "%#{string}%"
  end
end

Post.where.has { sift(:name_contains, 'joe') }
# File lib/baby_squeel/active_record/base.rb, line 31
def sifter(name, &block)
  define_singleton_method "sift_#{name}" do |*args|
    DSL.evaluate_sifter(self, *args, &block)
  end
end