Sha256: f1a9a6944baa684ee5acc1407f47de4df1a4a8a806c9c1d1bad6547cdc11e6c8
Contents?: true
Size: 729 Bytes
Versions: 2
Compression:
Stored size: 729 Bytes
Contents
# frozen_string_literal: true module TinyFilter module Concern class << self def included(other) if defined?(ActiveRecord::Base) && other <= ActiveRecord::Base other.scope :filter_by, ->(args = {}) { TinyFilter::FilterFinder.find(self).filter(self, args) } elsif defined?(Sequel::Model) && other <= Sequel::Model other.dataset_module do def filter_by(args = {}) TinyFilter::FilterFinder.find(self).filter(self, args) end end else raise Error, "unable to include TinyFilter::Concern in #{other} " \ "that is not an ActiveRecord::Base or Sequel::Model descendant" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tiny_filter-0.3.1 | lib/tiny_filter/concern.rb |
tiny_filter-0.3.0 | lib/tiny_filter/concern.rb |