Skip to content

Instantly share code, notes, and snippets.

@maxim
Forked from AJFaraday/foobar.rb
Created February 17, 2016 16:51
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 maxim/c3a6c11d1260fa581a0d to your computer and use it in GitHub Desktop.
Save maxim/c3a6c11d1260fa581a0d to your computer and use it in GitHub Desktop.
module Widgets
def self.extended(base)
class << base
attr_accessor :widgets
end
base.widgets = {}
end
def add_widget(name, widget)
widgets[name] = widget
end
end
class Foo
extend Widgets
end
class Bar
extend Widgets
end
Foo.add_widget('foo', :bar)
Bar.widgets['foo']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment