Created
May 14, 2015 02:29
-
-
Save ippeiukai/c9ea3bd91d2b63eb5889 to your computer and use it in GitHub Desktop.
Have you ever wanted to use def_single_delegator from SingleForwardable but still continue to use `delegate` of ActiveSupport?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module UseSingleForwardableWithActiveSupport | |
extend ActiveSupport::Concern | |
included do | |
original_delegate_method = method(:delegate).unbind if self.respond_to?(:delegate) | |
extend SingleForwardable | |
if original_delegate_method.present? | |
# restore the delegate of ActiveSupport that has been overshadowed by SingleForwardable | |
define_singleton_method :delegate, original_delegate_method | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment