Skip to content

Instantly share code, notes, and snippets.

@agoose77
Created August 28, 2015 14:43
Show Gist options
  • Save agoose77/a52d368ef3b9c0ceea13 to your computer and use it in GitHub Desktop.
Save agoose77/a52d368ef3b9c0ceea13 to your computer and use it in GitHub Desktop.
import hive
def build_foo_hive(i, ex, args):
i.foo_mod = hive.modifier(lambda h: print("Foo Plugin called!")
ex.plugin_foo = hive.plugin(i.foo_mod)
FooHive = hive.hive("FooHive", build_foo_hive)
def build_bar_hive(i, ex, args):
i.bar_mod = hive.modifier(lambda h: print("Bar Plugin called!")
ex.plugin_bar = hive.plugin(i.bar_mod)
BarHive = hive.hive("BarHive", build_bar_hive)
class SomeClass:
def accept_plugin(self, plugin):
plugin()
def build_some_hive(cls, i, ex, args):
i.mod = hive.modifier(lambda h: print("Some Plugin called!")
ex.plugin = hive.plugin(i.mod)
ex.socket = hive.socket(cls.accept_plugin, policy_cls=hive.socket_policies.MultipleOptional)
hive.connect(ex.plugin_foo, ex.socket)
hive.connect(ex.plugin_bar, ex.socket)
hive.connect(ex.plugin, ex.socket)
SomeHive = hive.hive("SomeHive", build_some_hive, parent_hives=(FooHive, BarHive))
h = SomeHive()
# >> Foo Plugin Called
# >> Bar Plugin Called
# >> Some Plugin Called
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment