Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Spell: Class Extension
# ======================
# Spell: Class Extension
# ======================
# Define class methods by mixing a module into a class’s singleton class
# (a special case of Object Extension -
class C; end
module M
def my_method
'a class method'
class << C
include M
C.my_method # => "a class method"
# For more information:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment