Skip to content

Instantly share code, notes, and snippets.

@bguthrie
Created March 27, 2009 17:55
Show Gist options
  • Save bguthrie/86801 to your computer and use it in GitHub Desktop.
Save bguthrie/86801 to your computer and use it in GitHub Desktop.
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