Module: MergeFilter::ClassMethods
- Defined in:
- lib/merge_filter.rb
Instance Method Summary collapse
Instance Method Details
#default_scope(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/merge_filter.rb', line 12 def default_scope &block define_method :default_scope do if block_given? yield else fail NotImplementedError, "You need to supply a default_scope." end end end |
#filter_by(column, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/merge_filter.rb', line 22 def filter_by column, &block define_method column do |*args| if block_given? yield filter.fetch(column), default_scope else default_scope.where(column => args) end end end |