Skip to content

Instantly share code, notes, and snippets.

@maxim maxim/foobar.rb forked from AJFaraday/foobar.rb
Created Feb 17, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.