Sha256: 7148b6f5e617017d425b2b8e1f122d40a98ac576cc062b7b44a13dd25af37c79

Contents?: true

Size: 389 Bytes

Versions: 3

Compression:

Stored size: 389 Bytes

Contents

# frozen_string_literal: true

module Filta
  module Methods
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def filta(by)
        results = where(nil)

        by.each do |key, value|
          next if value.to_s.blank?

          results = results.where(key.to_s.to_sym => value)
        end

        results
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
filta-4.0.0 lib/filta/methods.rb
filta-3.0.0 lib/filta/methods.rb
filta-2.1.0 lib/filta/methods.rb