aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorJames Mead <james@floehopper.org>2008-08-29 15:08:16 -0500
committerJoshua Peek <josh@joshpeek.com>2008-08-29 15:09:47 -0500
commit3cf773b187e803e16b8237e5923fa4c1139cde8a (patch)
treed1d62af672f28c39f7bafa980f0dd35d9ddfcc47 /actionmailer/lib
parent99492bad885aa0ee44c770e2c61ad36c3058c697 (diff)
downloadrails-3cf773b187e803e16b8237e5923fa4c1139cde8a.tar.gz
rails-3cf773b187e803e16b8237e5923fa4c1139cde8a.tar.bz2
rails-3cf773b187e803e16b8237e5923fa4c1139cde8a.zip
ActionMailer should respond_to? to methods handled by method_missing [#700 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionmailer/lib')
-rw-r--r--actionmailer/lib/action_mailer/base.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 72c94529b5..5b3c560390 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -374,11 +374,16 @@ module ActionMailer #:nodoc:
alias_method :controller_name, :mailer_name
alias_method :controller_path, :mailer_name
- def method_missing(method_symbol, *parameters)#:nodoc:
- case method_symbol.id2name
- when /^create_([_a-z]\w*)/ then new($1, *parameters).mail
- when /^deliver_([_a-z]\w*)/ then new($1, *parameters).deliver!
- when "new" then nil
+ def respond_to?(method_symbol, include_private = false) #:nodoc:
+ matches_dynamic_method?(method_symbol) || super
+ end
+
+ def method_missing(method_symbol, *parameters) #:nodoc:
+ match = matches_dynamic_method?(method_symbol)
+ case match[1]
+ when 'create' then new(match[2], *parameters).mail
+ when 'deliver' then new(match[2], *parameters).deliver!
+ when 'new' then nil
else super
end
end
@@ -424,6 +429,12 @@ module ActionMailer #:nodoc:
def template_root=(root)
self.view_paths = ActionView::Base.process_view_paths(root)
end
+
+ private
+ def matches_dynamic_method?(method_name) #:nodoc:
+ method_name = method_name.to_s
+ /(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name)
+ end
end
# Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer