Skip to content

Instantly share code, notes, and snippets.

@kjlape
Created July 24, 2017 13:38
Show Gist options
  • Select an option

  • Save kjlape/e77c41c2353a711896dc90ad5c094ba0 to your computer and use it in GitHub Desktop.

Select an option

Save kjlape/e77c41c2353a711896dc90ad5c094ba0 to your computer and use it in GitHub Desktop.
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