Created
January 13, 2009 10:42
-
-
Save samaaron/46396 to your computer and use it in GitHub Desktop.
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' | |
class John | |
end | |
j_c = John.class_eval do | |
def hi | |
'hi' | |
end | |
class << self | |
def friendly_param(parameter_name) | |
cattr_accessor :friendly_param | |
self.friendly_param = parameter_name.to_s | |
end | |
end | |
self | |
end | |
j_i = John.instance_eval do | |
def hi | |
'yo' | |
end | |
class << self | |
def friendly_param(parameter_name) | |
cattr_accessor :friendly_param | |
self.friendly_param = parameter_name.to_s | |
end | |
end | |
self | |
end | |
puts j_c == j_i | |
John.friendly_param :beans | |
puts John.friendly_param #=> beans | |
puts John.new.hi | |
puts John.friendly_param #=> beans | |
puts John.hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment