Sha256: 718af8506939ec305cca7295de6f507c170cc25b46cad52ff0de070326bd77d2

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 Jsonb::QueryMethods < QueryMethods
        include PgQueryMethods

        def matches(key, locale)
          build_op(key)[locale]
        end

        def exists(key, locale)
          build_op(key).has_key?(locale)
        end

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

        private

        def build_op(key)
          ::Sequel.pg_jsonb_op(column_name(key))
        end
      end
      Jsonb.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/jsonb/query_methods.rb
mobility-0.7.5 lib/mobility/backends/sequel/jsonb/query_methods.rb
mobility-0.7.4 lib/mobility/backends/sequel/jsonb/query_methods.rb
mobility-0.7.3 lib/mobility/backends/sequel/jsonb/query_methods.rb
mobility-0.7.2 lib/mobility/backends/sequel/jsonb/query_methods.rb
mobility-0.7.1 lib/mobility/backends/sequel/jsonb/query_methods.rb
mobility-0.7.0 lib/mobility/backends/sequel/jsonb/query_methods.rb
mobility-0.6.0 lib/mobility/backends/sequel/jsonb/query_methods.rb