Sha256: 8b3dde790b9c1d0a9f178f6627ebcdcad0ad83110ae9d2129a468a1df091111d
Contents?: true
Size: 1.46 KB
Versions: 10
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true module PaperTrail module Queries module Versions # For public API documentation, see `where_attribute_changes` in # `paper_trail/version_concern.rb`. # @api private class WhereAttributeChanges # - version_model_class - The class that VersionConcern was mixed into. # - attribute - An attribute that changed. See the public API # documentation for details. # @api private def initialize(version_model_class, attribute) @version_model_class = version_model_class @attribute = attribute end # @api private def execute if PaperTrail.config.object_changes_adapter.respond_to?(:where_attribute_changes) return PaperTrail.config.object_changes_adapter.where_attribute_changes( @version_model_class, @attribute ) end column_type = @version_model_class.columns_hash["object_changes"].type case column_type when :jsonb, :json json else raise UnsupportedColumnType.new( method: "where_attribute_changes", expected: "json or jsonb", actual: column_type ) end end private # @api private def json sql = "object_changes -> ? IS NOT NULL" @version_model_class.where(sql, @attribute) end end end end end
Version data entries
10 entries across 10 versions & 2 rubygems