Sha256: 12906ce6b6911067b170ea3a0c3ca7cf25d5725ae3d4a9aca445fc1434293062

Contents?: true

Size: 642 Bytes

Versions: 2

Compression:

Stored size: 642 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
    class ActiveRecord::Json::QueryMethods < ActiveRecord::QueryMethods
      include ActiveRecord::PgQueryMethods

      private

      def matches(key, value, locale)
        build_locale_infix(key, locale).eq(value.to_s)
      end

      def has_locale(key, locale)
        build_locale_infix(key, locale).eq(nil).not
      end

      def build_locale_infix(key, locale)
        build_infix(:'->>', arel_table[key], quote(locale))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mobility-0.5.1 lib/mobility/backends/active_record/json/query_methods.rb
mobility-0.5.0 lib/mobility/backends/active_record/json/query_methods.rb