File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
actionpack/lib/abstract_controller Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,20 @@ module Callbacks
35
35
skip_after_callbacks_if_terminated : true
36
36
end
37
37
38
+ class ActionFilter
39
+ def initialize ( actions )
40
+ @actions = Array ( actions ) . map ( &:to_s ) . to_set
41
+ end
42
+
43
+ def match? ( controller )
44
+ @actions . include? ( controller . action_name )
45
+ end
46
+
47
+ alias after match?
48
+ alias before match?
49
+ alias around match?
50
+ end
51
+
38
52
module ClassMethods
39
53
# If +:only+ or +:except+ are used, convert the options into the
40
54
# +:if+ and +:unless+ options of ActiveSupport::Callbacks.
@@ -62,8 +76,7 @@ def _normalize_callback_options(options)
62
76
63
77
def _normalize_callback_option ( options , from , to ) # :nodoc:
64
78
if from = options . delete ( from )
65
- _from = Array ( from ) . map ( &:to_s ) . to_set
66
- from = proc { |c | _from . include? c . action_name }
79
+ from = ActionFilter . new ( from )
67
80
options [ to ] = Array ( options [ to ] ) . unshift ( from )
68
81
end
69
82
end
You can’t perform that action at this time.
0 commit comments