Class: Contrast::Framework::Rails::Rewrite::ActiveRecordAttributeMethodsRead Deprecated
- Inherits:
-
Object
- Object
- Contrast::Framework::Rails::Rewrite::ActiveRecordAttributeMethodsRead
- Defined in:
- lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb
Overview
Deprecated.
Changes to this class are discouraged as this approach is being phased out with support for those language versions.
Rails / ActiveRecord are sneaky. They define attributes of a class in one method, then monkey patch allocate in another and finally invoke module_eval in this method… but of course they use a ‘tmp’ header for the method name and then alias it in this module to name it what we expect
TODO: RUBY-714 remove w/ EOL of 2.5
Class Method Summary collapse
Class Method Details
.instrument ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb', line 18 def self.instrument @_instrument ||= begin ::ActiveRecord::AttributeMethods::Read::ClassMethods.class_eval do alias_method :cs__patched_define_method_attribute, :define_method_attribute def define_method_attribute *args, &block ret = cs__patched_define_method_attribute(*args, &block) method_name = args[0] Contrast::Agent::Assess::Policy::Patcher.patch_assess_method(self, method_name) ret end protected :cs__patched_define_method_attribute, :define_method_attribute end true end end |