Sha256: acfe2005e9ee6b55e489082cb9d558316ec643c8d53e46feaa32631d25124b63

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module Contrast
  module Framework
    module Rails
      module Rewrite
        # Used to monkey patch all the inherited calls in action_pack
        # TODO: RUBY-714 remove w/ EOL of 2.5
        # @deprecated Changes to this class are discouraged as this approach is
        #   being phased out with support for those language versions.
        class ActiveRecordTimeZoneInherited
          def self.instrument
            @_instrument ||= begin
                               ::ActiveRecord::AttributeMethods::TimeZoneConversion::ClassMethods.class_eval do
                                 private

                                 alias_method :cs__patched_inherited, :inherited
                                 def inherited klass
                                   klass&.instance_variable_set(:@cs__defining_class, true)
                                   cs__patched_inherited(klass)
                                 ensure
                                   klass&.instance_variable_set(:@cs__defining_class, false)
                                 end
                               end
                               true
                             end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-3.13.2 lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb
contrast-agent-3.13.1 lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb
contrast-agent-3.13.0 lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb
contrast-agent-3.12.2 lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb
contrast-agent-3.12.1 lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb
contrast-agent-3.12.0 lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb