Sha256: 1507a1ce3806407234a2729df18c6b3ff4d3fdca4474e9b8b23b9b8c6de94c96

Contents?: true

Size: 801 Bytes

Versions: 21

Compression:

Stored size: 801 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    module Collection
      module Type
        class String < Value
          include ActiveRecord::Sanitization::ClassMethods

          attr_reader :exact
          alias_method :exact?, :exact

          delegate :type, :serialize, :deserialize, :cast, to: :@delegate

          def initialize(exact: false, **)
            super(**)

            @exact = exact
            @delegate = ActiveModel::Type::String.new
          end

          private

          def filter_condition(model, column, value)
            if exact? || scope
              super
            else
              model.where(model.arel_table[column].matches("%#{sanitize_sql_like(value)}%"))
            end
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
katalyst-tables-3.6.2 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.6.1 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.6.0 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.5.5 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.5.4 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.5.3 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.5.2 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.5.1 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.5.0 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.4.6 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.4.5 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.4.4 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.4.3 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.4.2 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.4.1 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.4.0 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.3.4 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.3.3 lib/katalyst/tables/collection/type/string.rb
katalyst-tables-3.3.2 app/models/katalyst/tables/collection/type/string.rb
katalyst-tables-3.3.1 app/models/katalyst/tables/collection/type/string.rb