Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 6464214

Browse files
committed
drop render_overridable in favor of letting AV handle it to better match master.
this does create a new ActionView dependency, though
1 parent cc9e15f commit 6464214

File tree

2 files changed

+14
-33
lines changed

2 files changed

+14
-33
lines changed

lib/exception_notifier.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2222
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323
class ExceptionNotifier < ActionMailer::Base
24+
self.mailer_name = 'exception_notifier'
25+
self.view_paths << "#{File.dirname(__FILE__)}/../views"
26+
2427
@@sender_address = %("Exception Notifier" <[email protected]>)
2528
cattr_accessor :sender_address
2629

@@ -33,8 +36,6 @@ class ExceptionNotifier < ActionMailer::Base
3336
@@sections = %w(request session environment backtrace)
3437
cattr_accessor :sections
3538

36-
self.template_root = "#{File.dirname(__FILE__)}/../views"
37-
3839
def self.reloadable?() false end
3940

4041
def exception_notification(exception, controller, request, data={})
@@ -60,15 +61,15 @@ def self.exception_source(controller)
6061
end
6162
end
6263

63-
private
64+
private
6465

65-
def sanitize_backtrace(trace)
66-
re = Regexp.new(/^#{Regexp.escape(rails_root)}/)
67-
trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s }
68-
end
66+
def sanitize_backtrace(trace)
67+
re = Regexp.new(/^#{Regexp.escape(rails_root)}/)
68+
trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s }
69+
end
6970

70-
def rails_root
71-
@rails_root ||= Pathname.new(RAILS_ROOT).cleanpath.to_s
72-
end
71+
def rails_root
72+
@rails_root ||= Pathname.new(RAILS_ROOT).cleanpath.to_s
73+
end
7374

7475
end

lib/exception_notifier_helper.rb

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,19 @@
2121
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2222
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323
module ExceptionNotifierHelper
24-
EXCEPTION_NOTIFIER_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
25-
VIEW_PATH = "views/exception_notifier"
26-
RAILS_VIEW_PATH = "#{RAILS_ROOT}/app/#{VIEW_PATH}"
2724
PARAM_FILTER_REPLACEMENT = "[FILTERED]"
2825

2926
def render_section(section)
3027
RAILS_DEFAULT_LOGGER.info("rendering section #{section.inspect}")
31-
summary = render_overridable(section).strip
28+
summary = render("exception_notifier/#{section}").strip
3229
unless summary.blank?
33-
title = render_overridable(:title, :locals => { :title => section }).strip
30+
title = render("exception_notifier/title", :locals => { :title => section }).strip
3431
"#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
3532
end
3633
end
3734

38-
def render_overridable(partial, options={})
39-
paths = partial_paths(partial)
40-
if path = paths.find {|p| File.exist?(p) }
41-
render(options.merge(:file => path, :use_full_path => false))
42-
else
43-
""
44-
end
45-
end
46-
47-
def partial_paths(partial)
48-
exts = %w{ rhtml html.erb }
49-
exts.map {|ext|
50-
[ "#{RAILS_VIEW_PATH}/_#{partial}.#{ext}",
51-
"#{EXCEPTION_NOTIFIER_PATH}/#{VIEW_PATH}/_#{partial}.#{ext}"]
52-
}.flatten
53-
end
54-
5535
def inspect_model_object(model, locals={})
56-
render_overridable(:inspect_model,
36+
render('exception_notifier/inspect_model',
5737
:locals => { :inspect_model => model,
5838
:show_instance_variables => true,
5939
:show_attributes => true }.merge(locals))

0 commit comments

Comments
 (0)