Sha256: 5683c40f88b27b260063905c0d49c8c8156b0a614837b3fca3425aa16544f10d

Contents?: true

Size: 440 Bytes

Versions: 4

Compression:

Stored size: 440 Bytes

Contents

# frozen_string_literal: true

module TinyFilter
  module Concern
    extend ActiveSupport::Concern

    included do
      if defined?(ActiveRecord::Base) && self <= ActiveRecord::Base
        scope :filter_by, ->(args = {}) { TinyFilter::FilterFinder.find(self).filter(self, args) }
      else
        raise Error, "unable to include TinyFilter::Concern in #{self} that is not an ActiveRecord::Base descendant"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tiny_filter-0.2.1 lib/tiny_filter/concern.rb
tiny_filter-0.2.0 lib/tiny_filter/concern.rb
tiny_filter-0.1.1 lib/tiny_filter/concern.rb
tiny_filter-0.1.0 lib/tiny_filter/concern.rb