Skip to content

Instantly share code, notes, and snippets.

@IdahoEv
Created April 17, 2014 20:06
Show Gist options
  • Save IdahoEv/11008551 to your computer and use it in GitHub Desktop.
Save IdahoEv/11008551 to your computer and use it in GitHub Desktop.
module UsefulStuff
module ClassMethods
def thing_count
@thing_count ||= 0
end
def set_count(val)
@thing_count = val
end
end
def self.included(base)
base.extend ClassMethods
end
end
class Foo
include UsefulStuff
end
class Bar
include UsefulStuff
end
Foo.set_count(4)
Bar.set_count(5)
p Foo.thing_count
p Bar.thing_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment