Sha256: 2bc9fbb030c91cbb04266df99e443b88d615280367a1f4a14341946d6e04f0a7

Contents?: true

Size: 1.45 KB

Versions: 11

Compression:

Stored size: 1.45 KB

Contents

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

return unless RUBY_VERSION < '2.6.0' # TODO: RUBY-714 remove guard w/ EOL of 2.5

module Contrast
  module Framework
    module Rails
      module Rewrite
        # Used to monkey patch all the inherited calls in action_pack
        #
        # This is the usual entry point for Rails inheritance work, so it should
        # catch most of the calls to inherited.
        # 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.
        module ActionControllerRailtiesHelperInherited
          def self.instrument
            @_instrument ||= begin
              ::ActionController::Railties::Helpers.class_eval do
                alias_method :cs__patched_helper_inherited, :inherited
                def inherited klass # rubocop:disable Lint/MissingSuper
                  klass&.instance_variable_set(:@cs__defining_class, true)
                  # This calls the original inherited, which should handle super as needed.
                  cs__patched_helper_inherited(klass)
                ensure
                  klass&.instance_variable_set(:@cs__defining_class, false)
                end
              end
              true
            end
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
contrast-agent-4.14.1 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.14.0 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.13.1 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.13.0 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.12.0 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.11.0 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.10.0 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.9.1 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.9.0 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.8.0 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb
contrast-agent-4.7.0 lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb