Sha256: 4297cbb75d05d9226828fd04a1b3bffa6776be94ce5e6d76d5485ceb87892143
Contents?: true
Size: 620 Bytes
Versions: 102
Compression:
Stored size: 620 Bytes
Contents
module Spree module Core module QueryFilters class Text def initialize(attribute:) @attribute = attribute end def call(scope:, filter:) scope = eq(scope, filter[:eq]) contains(scope, filter[:contains]) end private attr_reader :attribute def eq(scope, value) return scope unless value scope.where(attribute.eq(value)) end def contains(scope, value) return scope unless value scope.where(attribute.matches("%#{value}%")) end end end end end
Version data entries
102 entries across 102 versions & 1 rubygems