Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created July 12, 2010 00:57
Show Gist options
  • Select an option

  • Save practicingruby/471995 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/471995 to your computer and use it in GitHub Desktop.
class A
def self.extensions
@extensions ||= []
end
def self.run
@extensions.each do |klass|
klass.new.hello
end
end
end
class B
def hello
puts "hello from B"
end
A.extensions << self
end
class C
def hello
puts "hello from C"
end
A.extensions << self
end
A.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment