aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb5
-rw-r--r--activesupport/lib/active_support/core_ext/module/attr_internal.rb4
2 files changed, 3 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index d2bcd7a778..576366e496 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -61,10 +61,7 @@ class Class
end
RUBY
- if instance_writer
- body = "def #{name}=(value) @#{name} = value end"
- class_eval body, __FILE__, __LINE__ - 1
- end
+ attr_writer name if instance_writer
end
end
end
diff --git a/activesupport/lib/active_support/core_ext/module/attr_internal.rb b/activesupport/lib/active_support/core_ext/module/attr_internal.rb
index d052bfed2d..28bc30ae26 100644
--- a/activesupport/lib/active_support/core_ext/module/attr_internal.rb
+++ b/activesupport/lib/active_support/core_ext/module/attr_internal.rb
@@ -2,14 +2,14 @@ class Module
# Declares an attribute reader backed by an internally-named instance variable.
def attr_internal_reader(*attrs)
attrs.each do |attr|
- module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end"
+ module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end", __FILE__, __LINE__
end
end
# Declares an attribute writer backed by an internally-named instance variable.
def attr_internal_writer(*attrs)
attrs.each do |attr|
- module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end"
+ module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end", __FILE__, __LINE__
end
end