Skip to content

Instantly share code, notes, and snippets.

@samaaron
Created January 13, 2009 10:42
Show Gist options
  • Save samaaron/46396 to your computer and use it in GitHub Desktop.
Save samaaron/46396 to your computer and use it in GitHub Desktop.
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