Skip to content

Instantly share code, notes, and snippets.

@claudiolassala
Created February 9, 2012 05:19
Show Gist options
  • Save claudiolassala/1777547 to your computer and use it in GitHub Desktop.
Save claudiolassala/1777547 to your computer and use it in GitHub Desktop.
module SomeNamespace::SomeModule
# how do I get this method mixed into the class below?
def some_module_method(x, y, z)
end
end
class SomeNamespace::SomeClass
# include SomeNamespace::SomeModule
# update: it seems like instead of "include", I should use "extend"...
extend SomeNamespace::SomeModule
def self.some_class_method
some_module_method(1, 2, 3)
end
end
@jakcharlton
Copy link

module SomeModule

  # how do I get this method mixed into the class below?
  def some_module_method(x, y, z)
     p "called"
  end
end

class SomeClass
  extend SomeModule

  def self.some_class_method
    some_module_method(1, 2, 3)
  end
end

SomeClass.some_class_method  #=> "called"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment