Module: Carioca::Injector

Included in:
Container, Services::SecureStore
Defined in:
lib/carioca/mixin.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



26
27
28
# File 'lib/carioca/mixin.rb', line 26

def self.extended(base)
  base.include self
end

Instance Method Details

#active_servicesObject



17
18
19
# File 'lib/carioca/mixin.rb', line 17

def active_services
  Carioca::Registry.get.active_services
end

#add(service:, definition:) ⇒ Object



9
10
11
# File 'lib/carioca/mixin.rb', line 9

def add(service:, definition:)
  Carioca::Registry.get.add service:, definition:
end

#create_methods(name) ⇒ Object



21
22
23
24
# File 'lib/carioca/mixin.rb', line 21

def create_methods(name, &)
  define_method(name, &)
  self.class.send(:define_method, name, &)
end

#inject(service:) ⇒ Object



5
6
7
# File 'lib/carioca/mixin.rb', line 5

def inject(service:)
  create_methods(service) { return Carioca::Registry.get.get_service name: service }
end

#servicesObject



13
14
15
# File 'lib/carioca/mixin.rb', line 13

def services
  Carioca::Registry.get.services
end