Sha256: 81ecac789e9eb410432aa9482e70507694b25f0430bf3b55e7ec6e35bbe3b776

Contents?: true

Size: 612 Bytes

Versions: 6

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true

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

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

    def services
      Carioca::Registry.get.services
    end

    def active_services
      Carioca::Registry.get.active_services
    end

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
carioca-2.1.10 lib/carioca/mixin.rb
carioca-2.1.9 lib/carioca/mixin.rb
carioca-2.1.8 lib/carioca/mixin.rb
carioca-2.1.7 lib/carioca/mixin.rb
carioca-2.1.6 lib/carioca/mixin.rb
carioca-2.1.5 lib/carioca/mixin.rb