Class: Payload::Definition Private

Inherits:
Object
  • Object
show all
Defined in:
lib/payload/definition.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Definition for a dependency which can be resolved and decorated.

Used internally by DefinitionList. Use Container#service or Container#factory.

Instance Method Summary collapse

Constructor Details

#initialize(name, resolver, decorators = DecoratorChain.new) ⇒ Definition

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Definition.



12
13
14
15
16
# File 'lib/payload/definition.rb', line 12

def initialize(name, resolver, decorators = DecoratorChain.new)
  @name = name
  @resolver = resolver
  @decorators = decorators
end

Instance Method Details

#==(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
# File 'lib/payload/definition.rb', line 30

def ==(other)
  other.is_a?(Definition) &&
    name == other.name &&
    resolver == other.resolver &&
    decorators == other.decorators
end

#decorate(decorator) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def decorate(decorator)
  self.class.new name, resolver, decorators.add(decorator)
end

#resolve(container) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
# File 'lib/payload/definition.rb', line 18

def resolve(container)
  resolver.resolve(container, decorators)
end

#set(_) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def set(_)
  raise DependencyAlreadyDefinedError, "#{name} is already defined"
end