Sha256: 97add67f13a48d535d753e420975b8b02edefe76895d65e6e7634712f6c0a7b9
Contents?: true
Size: 683 Bytes
Versions: 16
Compression:
Stored size: 683 Bytes
Contents
module Trax module Model module Matchable extend ::ActiveSupport::Concern included do ::String.class_eval do def to_matchable "%#{self.strip}%" end end end module ClassMethods def matching(args = {}) matches = args.inject(self.all) do |scope, (key, value)| node = key.is_a?(Symbol) ? self.arel_table[key] : key values = [value] match_values = values.flatten.compact.uniq.map!(&:to_matchable) scope = scope.where(node.matches_any(match_values)) scope end matches end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems