Created
July 24, 2017 13:38
-
-
Save kjlape/e77c41c2353a711896dc90ad5c094ba0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class WithTranslation | |
| def initialize(delegate, translator) | |
| @delegate = delegate | |
| @translator = translator | |
| end | |
| def method_missing(method_name, *rest) | |
| translation = @translator.translate_attribute(@delegate, method_name) | |
| return translation if translation.present? | |
| @delegate.public_send method_name, *rest | |
| end | |
| def responds_to?(method_name) | |
| @delegate.responds_to? method_name | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment