Module: ServiceProvider

Defined in:
lib/service_provider.rb,
lib/service_provider/version.rb,
lib/service_provider/provider/automatic.rb,
lib/service_provider/method_decorators/provides.rb,
lib/service_provider/method_decorators/requires.rb

Defined Under Namespace

Modules: MethodDecorators, Provider

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.providerObject



22
23
24
# File 'lib/service_provider.rb', line 22

def self.provider
  @provider ||= ServiceProvider::Provider::Automatic
end

.provider=(provider) ⇒ Object



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

def self.provider=(provider)
  @provider = provider
end

Instance Method Details

#method_added(method_name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/service_provider.rb', line 11

def method_added(method_name)
  super

  decorators = MethodDecorator.current_decorators
  return if decorators.empty?

  provider_decorator = find_and_remove_provider_decorator!(decorators)
  call_original_method_with_other_decorators(method_name, decorators)
  add_provider_service_to_service_provider(provider_decorator.service_name) if provider_decorator
end