Sha256: ae6ed25d63723af0178e9f4e8b2419c1b4ef16161edeee8abe3fd914b1fc26e9

Contents?: true

Size: 714 Bytes

Versions: 8

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true
require "mobility/backends/sequel/pg_query_methods"
require "mobility/backends/sequel/query_methods"

Sequel.extension :pg_json, :pg_json_ops

module Mobility
  module Backends
    module Sequel
      class Json::QueryMethods < QueryMethods
        include PgQueryMethods

        def matches(key, locale)
          build_op(key).get_text(locale)
        end

        def exists(key, locale)
          matches(key, locale) !~ nil
        end

        def quote(value)
          value && value.to_s
        end

        private

        def build_op(key)
          ::Sequel.pg_json_op(column_name(key))
        end
      end
      Json.private_constant :QueryMethods
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mobility-0.7.6 lib/mobility/backends/sequel/json/query_methods.rb
mobility-0.7.5 lib/mobility/backends/sequel/json/query_methods.rb
mobility-0.7.4 lib/mobility/backends/sequel/json/query_methods.rb
mobility-0.7.3 lib/mobility/backends/sequel/json/query_methods.rb
mobility-0.7.2 lib/mobility/backends/sequel/json/query_methods.rb
mobility-0.7.1 lib/mobility/backends/sequel/json/query_methods.rb
mobility-0.7.0 lib/mobility/backends/sequel/json/query_methods.rb
mobility-0.6.0 lib/mobility/backends/sequel/json/query_methods.rb