Created
March 27, 2009 17:55
-
-
Save bguthrie/86801 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
module BetterToInteger | |
def self.included(string_class) | |
string_class.alias_method_chain :to_i, :logging | |
end | |
def to_i_with_logging | |
returning(to_i_without_logging) do |new_value| | |
logger.log "Converting from #{self} to #{new_value}" | |
end | |
end | |
end | |
String.send :include, BetterToInteger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment