Created
June 9, 2011 11:58
-
-
Save ream88/1016586 to your computer and use it in GitHub Desktop.
Translatable Concern
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 Translatable | |
extend ActiveSupport::Concern | |
module InstanceMethods | |
def method_missing(*args) | |
method = /(\w+)(.)?/.match(args.first).to_a.last(2) | |
method = "#{method.first}_#{args.second}#{method.second}" | |
if respond_to?(method) | |
send(method) | |
else | |
super | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment