Sha256: 841a7f20635e245c124aa5142ed14a6318731861e314ca68d91b6a1b61b5c7d0

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

# frozen_string_literal: true
require 'mobility/backends/active_record/pg_query_methods'
require "mobility/backends/active_record/query_methods"

module Mobility
  module Backends
    module ActiveRecord
      class Jsonb::QueryMethods < QueryMethods
        include PgQueryMethods

        def matches(key, locale)
          build_infix(:'->', arel_table[column_name(key)], build_quoted(locale))
        end

        def exists(key, locale)
          build_infix(:'?', arel_table[column_name(key)], build_quoted(locale))
        end

        def quote(value)
          build_quoted(value.to_json)
        end
      end
      Jsonb.private_constant :QueryMethods
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mobility-0.6.0 lib/mobility/backends/active_record/jsonb/query_methods.rb