Module: Rohbau::Registry::ExternalInterface
- Defined in:
- lib/rohbau/registry.rb
Instance Method Summary collapse
- #implementations ⇒ Object
- #register(service_name, &constructor) ⇒ Object
- #registrations ⇒ Object
- #unregister(service_name) ⇒ Object
Instance Method Details
#implementations ⇒ Object
38 39 40 |
# File 'lib/rohbau/registry.rb', line 38 def implementations @implementations ||= Hash.new { |hash, key| hash[key] = [] } end |
#register(service_name, &constructor) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/rohbau/registry.rb', line 16 def register(service_name, &constructor) implementations[service_name] << constructor define_method service_name do cache service_name do instance_eval(&self.class.implementations[service_name].last) end end end |
#registrations ⇒ Object
34 35 36 |
# File 'lib/rohbau/registry.rb', line 34 def registrations implementations.keys end |
#unregister(service_name) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rohbau/registry.rb', line 26 def unregister(service_name) implementations[service_name].pop if implementations[service_name].empty? remove_method service_name end end |