Sha256: be1760ebf6274c29bf89069ab372390ba5a6e03f8942eb7eaaf976ae310c7d56

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

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

module Mobility
  module Backends
    class ActiveRecord::Serialized::QueryMethods < ActiveRecord::QueryMethods
      include Serialized

      def initialize(attributes, _)
        super
        q = self

        define_method :where! do |opts, *rest|
          q.check_opts(opts) || super(opts, *rest)
        end
      end

      def extended(relation)
        super
        q = self

        mod = Module.new do
          define_method :not do |opts, *rest|
            q.check_opts(opts) || super(opts, *rest)
          end
        end
        relation.mobility_where_chain.include(mod)
      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/serialized/query_methods.rb
mobility-0.5.0 lib/mobility/backends/active_record/serialized/query_methods.rb