Skip to content

Instantly share code, notes, and snippets.

@besquared
Created September 12, 2009 02:40
Show Gist options
  • Select an option

  • Save besquared/185702 to your computer and use it in GitHub Desktop.

Select an option

Save besquared/185702 to your computer and use it in GitHub Desktop.
module MyModule
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def my_method
@myvar ||= 0
end
def my_method=(value)
@myvar = value
end
end
end
class MyClass
include MyModule
end
puts MyClass.my_method
MyClass.my_method = 5
puts MyClass.my_method
class AnotherClass
include MyModule
end
puts MyClass.my_method
puts AnotherClass.my_method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment