Class: Eggshell::Bundles::Registry
- Inherits:
-
Object
- Object
- Eggshell::Bundles::Registry
- Defined in:
- lib/eggshell/bundles.rb
Overview
Maintains central registry of bundles.
Constant Summary collapse
- @@reg =
{}
Class Method Summary collapse
- .attach_bundle(id, proc) ⇒ Object
- .get_bundle(id) ⇒ Object
- .register_bundle(bundle, id) ⇒ Object
- .unregister_bundle(id) ⇒ Object
Class Method Details
.attach_bundle(id, proc) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/eggshell/bundles.rb', line 46 def self.attach_bundle(id, proc) bundle = @@reg[id] if bundle bundle.new_instance(proc) else $stderr.write "no bundle '#{id}'\n" end end |
.get_bundle(id) ⇒ Object
42 43 44 |
# File 'lib/eggshell/bundles.rb', line 42 def self.get_bundle(id) return @@reg[id] end |
.register_bundle(bundle, id) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/eggshell/bundles.rb', line 28 def self.register_bundle(bundle, id) if !bundle.respond_to?(:new_instance) $stderr.write "registering bundle failed: #{bundle} does not have 'new_instance' method\n" return end if !@@reg[id] @@reg[id] = bundle $stderr.write "registering bundle #{id} => #{bundle}\n" else $stderr.write "registering bundle failed: #{id} already registered\n" end end |
.unregister_bundle(id) ⇒ Object
55 56 57 58 |
# File 'lib/eggshell/bundles.rb', line 55 def self.unregister_bundle(id) bundle = @@reg.delete(id) $stderr.write "unregistered bundle #{id} => #{bundle}\n" end |