Skip to content

Instantly share code, notes, and snippets.

@ramfjord
Created June 12, 2015 02:45
Show Gist options
  • Save ramfjord/415ca8135214f6d6910a to your computer and use it in GitHub Desktop.
Save ramfjord/415ca8135214f6d6910a to your computer and use it in GitHub Desktop.
module Test
module ClassMethods
attr_accessor :var
# Make everything in ClassMethods a class method on whatever includes this
def self.included(klass)
klass.extend ClassMethods
end
end
end
class Hello
include Test
@var = 3
end
Hello.var
# => NoMethodError: undefined method `var' for Hello:Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment