Skip to content

Commit 07e0e81

Browse files
committed
Use a respond_to? strategy instead
1 parent 61c75b3 commit 07e0e81

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/react/rails/controller_lifecycle.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module ControllerLifecycle
55

66
included do
77
# use both names to support Rails 3..5
8-
before_action_with_fallback = begin method(:before_action); rescue method(:before_filter); end
9-
after_action_with_fallback = begin method(:after_action); rescue method(:after_filter); end
10-
before_action_with_fallback.call :setup_react_component_helper
11-
after_action_with_fallback.call :teardown_react_component_helper
8+
before_action_with_fallback = respond_to?(:before_action) ? :before_action : :before_filter
9+
after_action_with_fallback = respond_to?(:after_action) ? :after_action : :after_filter
10+
public_send(before_action_with_fallback, :setup_react_component_helper)
11+
public_send(after_action_with_fallback, :teardown_react_component_helper)
1212
attr_reader :__react_component_helper
1313
end
1414

0 commit comments

Comments
 (0)