8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/remnant/rails.rb', line 8
def setup!
Remnant.configure do
environment ::Rails.env
end
::ActiveSupport::Dependencies.class_eval do
class << self
def clear_with_remnant_rediscover(*args, &block)
clear_without_remnant_rediscover(*args, &block).tap do
Remnant::Discover.rediscover!
end
end
alias_method_chain :clear, :remnant_rediscover
end
end
Remnant::Discover.find('request', ActionController::Dispatcher, :call)
Remnant::Discover.find('filters', ActionController::Filters::BeforeFilter, :call)
Remnant::Discover.find('action', ActionController::Base, :perform_action)
Remnant::Discover.find('view', ActionController::Base, :render)
Remnant::Discover.find('filters', ActionController::Filters::AfterFilter, :call)
::ActionController::Dispatcher.class_eval do
def call_with_remnant_discovery(*args, &block) call_without_remnant_discovery(*args, &block).tap do |status, , response|
begin
::Remnant.collect
::Rails.logger.flush if ::Rails.logger.respond_to? :flush
rescue Exception => e
if defined?(::Flail)
Flail::Exception.notify(e)
else
Rails.logger.error e.inspect
end
end
end
end
alias_method_chain :call, :remnant_discovery
end
::ActionController::Base.class_eval do
def perform_action_with_remnant_key(*args, &block) perform_action_without_remnant_key(*args, &block)
end
alias_method_chain :perform_action, :remnant_key
end
end
|