Skip to content

Instantly share code, notes, and snippets.

@pillowfactory
Created February 15, 2011 22:27
Show Gist options
  • Save pillowfactory/828394 to your computer and use it in GitHub Desktop.
Save pillowfactory/828394 to your computer and use it in GitHub Desktop.
How bad of practice is it to do something like this?
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