aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb b/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
index bfedbbb256..7b19aa059d 100644
--- a/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
+++ b/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
@@ -18,9 +18,8 @@ class Module
#
# attr_accessor_with_default(:element_name) { name.underscore }
#
- def attr_accessor_with_default(sym, default = nil, &block)
- raise 'Default value or block required' unless !default.nil? || block
- define_method(sym, block_given? ? block : Proc.new { default })
+ def attr_accessor_with_default(sym, default = Proc.new)
+ define_method(sym, block_given? ? default : Proc.new { default })
module_eval(<<-EVAL, __FILE__, __LINE__ + 1)
def #{sym}=(value) # def age=(value)
class << self; attr_reader :#{sym} end # class << self; attr_reader :age end