Class: Contrast::Framework::Rails::Rewrite::ActiveRecordTimeZoneInherited Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb

Overview

Deprecated.

Changes to this class are discouraged as this approach is being phased out with support for those language versions.

Used to monkey patch all the inherited calls in action_pack TODO: RUBY-714 remove w/ EOL of 2.5

Class Method Summary collapse

Class Method Details

.instrumentObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb', line 13

def self.instrument
  @_instrument ||= begin
    ::ActiveRecord::AttributeMethods::TimeZoneConversion::ClassMethods.class_eval do
      private

      alias_method :cs__patched_inherited, :inherited
      def inherited klass # rubocop:disable Lint/MissingSuper
        klass&.instance_variable_set(:@cs__defining_class, true)
        cs__patched_inherited(klass) # This calls the original inherited, which should handle super as needed.
      ensure
        klass&.instance_variable_set(:@cs__defining_class, false)
      end
    end
    true
  end
end