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

Version Path
spree_core-4.10.1 lib/spree/core/query_filters/text.rb
spree_core-4.10.0 lib/spree/core/query_filters/text.rb
spree_core-4.9.0 lib/spree/core/query_filters/text.rb
spree_core-4.8.3 lib/spree/core/query_filters/text.rb
spree_core-4.8.2 lib/spree/core/query_filters/text.rb
spree_core-4.7.3 lib/spree/core/query_filters/text.rb
spree_core-4.6.6 lib/spree/core/query_filters/text.rb
spree_core-4.5.5 lib/spree/core/query_filters/text.rb
spree_core-4.0.9 lib/spree/core/query_filters/text.rb
spree_core-4.1.15 lib/spree/core/query_filters/text.rb
spree_core-4.2.7 lib/spree/core/query_filters/text.rb
spree_core-4.3.3 lib/spree/core/query_filters/text.rb
spree_core-4.4.1 lib/spree/core/query_filters/text.rb
spree_core-4.5.4 lib/spree/core/query_filters/text.rb
spree_core-4.6.5 lib/spree/core/query_filters/text.rb
spree_core-4.7.2 lib/spree/core/query_filters/text.rb
spree_core-4.7.1 lib/spree/core/query_filters/text.rb
spree_core-4.6.4 lib/spree/core/query_filters/text.rb
spree_core-4.7.0 lib/spree/core/query_filters/text.rb
spree_core-4.6.3 lib/spree/core/query_filters/text.rb