17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/acts_as_warnable.rb', line 17
def warn_on_failure_of(*methods)
options = methods.last.is_a?(Hash) ? methods.pop : {}
methods.each do |method_name|
define_method "#{method_name}_with_warning" do |*args, &block|
begin
send("#{method_name}_without_warning", *args, &block)
rescue Exception => e
issue_warning(
warning_source(method_name),
"#{e.class.name}: #{e.message}\n\n#{e.backtrace.join("\n")}"
)
raise if options[:raise_anyway]
end
end
alias_method_chain method_name, :warning
end
end
|