Created
February 15, 2011 22:27
-
-
Save pillowfactory/828394 to your computer and use it in GitHub Desktop.
How bad of practice is it to do something like this?
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
require 'rubygems' | |
require 'active_support' | |
module CustomName | |
def self.included(base) | |
base.alias_method_chain :name, :update | |
end | |
def name_with_update | |
['custom', name_without_update].join(' ') | |
end | |
end | |
class Person | |
def name | |
'person' | |
end | |
end | |
Person.send(:include, CustomName) | |
p = Person.new | |
puts p.name #=> 'custom person' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment