Sha256: 222cc30375e2a61538fa48cb3443a7e37dc3765f6d1c7d782844c11ecfabbf45

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 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 Json::QueryMethods < QueryMethods
        include PgQueryMethods

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

        def exists(key, locale)
          absent(key, locale).not
        end

        def absent(key, locale)
          matches(key, locale).eq(nil)
        end

        def quote(value)
          value.to_s
        end
      end
      Json.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/json/query_methods.rb