aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
-rw-r--r--activesupport/lib/active_support/core_ext/module/attribute_accessors.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb b/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
index fe4f8a4fc0..8127150a96 100644
--- a/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
+++ b/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
@@ -3,6 +3,7 @@
class Module # :nodoc:
def mattr_reader(*syms)
syms.each do |sym|
+ next if sym.is_a?(Hash)
class_eval(<<-EOS, __FILE__, __LINE__)
unless defined? @@#{sym}
@@#{sym} = nil
@@ -20,6 +21,7 @@ class Module # :nodoc:
end
def mattr_writer(*syms)
+ options = syms.last.is_a?(Hash) ? syms.pop : {}
syms.each do |sym|
class_eval(<<-EOS, __FILE__, __LINE__)
unless defined? @@#{sym}
@@ -29,10 +31,12 @@ class Module # :nodoc:
def self.#{sym}=(obj)
@@#{sym} = obj
end
-
+
+ #{"
def #{sym}=(obj)
@@#{sym} = obj
end
+ " unless options[:instance_writer] == false }
EOS
end
end