Module: ServiceBureau::Services
- Defined in:
- lib/service_bureau/services.rb
Overview
When mixed in to a class, it provides a handle for all configured services. It also provides an injector method for each service so that altenative implementations can be easily injected e.g. for testing.
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/service_bureau/services.rb', line 23 def self.included(base) ServiceBureau::Locations.factory_map.keys.each do |service| # Provide a method to inject the service obj define_method "#{service}=" do |service_obj| __set_service__ service, service_obj end # Provide a handle to the service instance define_method service do |*args| __get_service__ service, *args end end end |