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 =
{}
- @@log_level =
0
Class Method Summary collapse
- .attach_bundle(id, proc) ⇒ Object
- .get_bundle(id) ⇒ Object
- .log_level(lvl) ⇒ Object
- .register_bundle(bundle, id) ⇒ Object
- .unregister_bundle(id) ⇒ Object
Class Method Details
.attach_bundle(id, proc) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/eggshell/bundles.rb', line 51 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
47 48 49 |
# File 'lib/eggshell/bundles.rb', line 47 def self.get_bundle(id) return @@reg[id] end |
.log_level(lvl) ⇒ Object
29 30 31 |
# File 'lib/eggshell/bundles.rb', line 29 def self.log_level(lvl) @@log_level = lvl end |
.register_bundle(bundle, id) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eggshell/bundles.rb', line 33 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" if @@log_level > 0 else $stderr.write "registering bundle failed: #{id} already registered\n" end end |
.unregister_bundle(id) ⇒ Object
60 61 62 63 |
# File 'lib/eggshell/bundles.rb', line 60 def self.unregister_bundle(id) bundle = @@reg.delete(id) $stderr.write "unregistered bundle #{id} => #{bundle}\n" end |