diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-21 07:29:33 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-21 07:29:33 +0000 |
commit | 5129de7bbdbd15e47ce5baf7945caf2e78d82882 (patch) | |
tree | 5821e5807d9eefc63374aece4f67d9e7833a49a8 /actionmailer/lib/action_mailer | |
parent | d1ac316fa4b3d2aae8314362a961d06f96922478 (diff) | |
download | rails-5129de7bbdbd15e47ce5baf7945caf2e78d82882.tar.gz rails-5129de7bbdbd15e47ce5baf7945caf2e78d82882.tar.bz2 rails-5129de7bbdbd15e47ce5baf7945caf2e78d82882.zip |
r3220@asus: jeremy | 2005-11-20 03:19:22 -0800
Enable Action Mailer warnings in unit tests. adv_attr_accessor hecks for presence of instance variable before getting it.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3132 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/adv_attr_accessor.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/actionmailer/lib/action_mailer/adv_attr_accessor.rb b/actionmailer/lib/action_mailer/adv_attr_accessor.rb index a8b83c5e64..50afe4d742 100644 --- a/actionmailer/lib/action_mailer/adv_attr_accessor.rb +++ b/actionmailer/lib/action_mailer/adv_attr_accessor.rb @@ -8,16 +8,20 @@ module ActionMailer module ClassMethods #:nodoc: def adv_attr_accessor(*names) names.each do |name| + ivar = "@#{name}" + define_method("#{name}=") do |value| - instance_variable_set("@#{name}", value) + instance_variable_set(ivar, value) end define_method(name) do |*parameters| raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1 if parameters.empty? - instance_variable_get("@#{name}") + if instance_variables.include?(ivar) + instance_variable_get(ivar) + end else - instance_variable_set("@#{name}", parameters.first) + instance_variable_set(ivar, parameters.first) end end end |