Skip to content

Instantly share code, notes, and snippets.

@Tonkpils
Created November 5, 2013 16:24
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 Tonkpils/7321671 to your computer and use it in GitHub Desktop.
Save Tonkpils/7321671 to your computer and use it in GitHub Desktop.
Showing an example of class instance variables.
module Bar
def self.included(base)
base.extend(ClassMethods)
end
def event_name
self.class.event
end
module ClassMethods
def event_name(name)
@event_name = name.to_sym
end
def event
@event_name
end
end
end
class Foo
include Bar
end
class Baz < Foo
event_name :cool
end
Baz.event
#=> :cool
Baz.new.event_name
#=> :cool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment