Sha256: c7b776700d62afa3ba6657bfa72ed2a2dbef9e0a3a9558623209c311948777d7

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

module Datagrid
  module Filters
    module CompositeFilters

      def self.included(base)
        base.extend         ClassMethods
        base.class_eval do

        end
        base.send :include, InstanceMethods
      end # self.included

      module ClassMethods


        def date_range_filters(field, from_name = :"from_#{field}", to_name = :"to_#{field}")
          filter(from_name, :date) do |date|
            self.from_date(date, field)
          end
          filter(to_name, :date) do |date|
            self.to_date(date, field)
          end
        end

        def integer_range_filters(field, from_name = :"from_#{field}", to_name = :"to_#{field}")
          filter(from_name, :integer) do |value|
            self.scoped(:conditions => "#{field} >= #{value}")
          end
          filter(to_name, :integer) do |value|
            self.scoped(:conditions => "#{field} <= #{value}")
          end
        end
      end # ClassMethods

      module InstanceMethods

      end # InstanceMethods

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
datagrid-0.3.5 lib/datagrid/filters/composite_filters.rb
datagrid-0.3.4 lib/datagrid/filters/composite_filters.rb
datagrid-0.3.3 lib/datagrid/filters/composite_filters.rb
datagrid-0.3.2 lib/datagrid/filters/composite_filters.rb
datagrid-0.3.1 lib/datagrid/filters/composite_filters.rb
datagrid-0.3.0 lib/datagrid/filters/composite_filters.rb
datagrid-0.2.0 lib/datagrid/filters/composite_filters.rb
datagrid-0.1.2 lib/datagrid/filters/composite_filters.rb
datagrid-0.1.1 lib/datagrid/filters/composite_filters.rb
datagrid-0.1.0 lib/datagrid/filters/composite_filters.rb
datagrid-0.0.3 lib/datagrid/filters/composite_filters.rb