Sha256: 2c0075513457ed1c0a6def8a88527b8ddb3354fdb27dd853dc87f260bbd64c21

Contents?: true

Size: 813 Bytes

Versions: 6

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module Care::AutoFinder
  module FinderMethods
    extend ActiveSupport::Concern

    included do
      include Care::AutoFinder::Paginateble
      include Care::AutoFinder::Searchable
      include Care::AutoFinder::Sortable
      include Care::AutoFinder::ByIds
    end

    def range_filter(options)
      options = Struct.new(*options.keys).new(*options.values)

      if options.start.present? && options.end.present?
        options.collection.where(options.column => options.start..options.end)
      elsif options.start.present?
        options.collection.where("#{options.column} >= ?", options.start)
      elsif options.end.present?
        options.collection.where("#{options.column} <= ?", options.end)
      else
        options.collection
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
care-0.1.6 lib/care/auto_finder/finder_methods.rb
care-0.1.5 lib/care/auto_finder/finder_methods.rb
care-0.1.4 lib/care/auto_finder/finder_methods.rb
care-0.1.3 lib/care/auto_finder/finder_methods.rb
care-0.1.1 lib/care/auto_finder/finder_methods.rb
care-0.1.0 lib/care/auto_finder/finder_methods.rb