Skip to content

Instantly share code, notes, and snippets.

@nogweii
Last active August 29, 2015 13:56
Show Gist options
  • Save nogweii/9104855 to your computer and use it in GitHub Desktop.
Save nogweii/9104855 to your computer and use it in GitHub Desktop.
Example module code for #ruby on Freenode
module MyBase
def big_function
@_memoized_big_function ||= begin
load_lots_of_data(SettingsManager.foo_bar)
end
end
module_method :big_function
public :big_function
end
class Chef
class Recipe
include MyBase
end
end
@nogweii
Copy link
Author

nogweii commented Feb 20, 2014

I had originally asked in #ruby on Freenode:

There is a way to get MyBase.big_function to work, right? https://gist.github.com/evaryont/9104855 Accessing an instance method of a module from a class method?

Which lead me to this StackOverflow question and the result is above.

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