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#fatory.

Instance Method Summary collapse

Constructor Details

#initialize(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
# File 'lib/payload/definition.rb', line 12

def initialize(resolver, decorators = DecoratorChain.new)
  @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.



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

def ==(other)
  other.is_a?(Definition) &&
    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.



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

def decorate(decorator)
  self.class.new 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.



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

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.



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

def set(_)
  raise DependencyAlreadyDefinedError
end