Skip to content

Instantly share code, notes, and snippets.

@chad
Created May 8, 2012 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chad/2635951 to your computer and use it in GitHub Desktop.
Save chad/2635951 to your computer and use it in GitHub Desktop.
module Foo
def self.included(klass)
klass.extend ClassMethods
end
module ClassMethods
def foo(name)
(class << self; self; end).send :attr_accessor, name
end
end
end
class Bar
include Foo
foo("test")
end
p Bar.test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment