Last active
December 10, 2015 14:49
-
-
Save nahi/4449729 to your computer and use it in GitHub Desktop.
You can create auto-encoding-detection version with your favorite logic. i.e. super(rhs.force_encoding(mydetect(rhs)))
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
require 'refinement' | |
module StringForceEncodingConcat | |
refine String do | |
def +(rhs) | |
begin | |
super | |
rescue Encoding::CompatibilityError | |
super(rhs.force_encoding(self.encoding)) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No "require 'refinement'" needed ATM.