Module: BabySqueel::ActiveRecord::Base
- Defined in:
- lib/baby_squeel/active_record/base.rb
Instance Method Summary collapse
-
#sifter(name, &block) ⇒ Object
Define a sifter that can be used within DSL blocks.
Instance Method Details
#sifter(name, &block) ⇒ Object
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') }
31 32 33 34 35 |
# 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 |