class Dio::LoadContext

LoadContext provides some information about current loading.

Attributes

args[R]

@!attribute [r] key

A key of a loaded dependency.

@!attribute [r] target

An instance which is injected to.

@!attribute [r] args

Passed arguments when loaded.
key[R]

@!attribute [r] key

A key of a loaded dependency.

@!attribute [r] target

An instance which is injected to.

@!attribute [r] args

Passed arguments when loaded.
target[R]

@!attribute [r] key

A key of a loaded dependency.

@!attribute [r] target

An instance which is injected to.

@!attribute [r] args

Passed arguments when loaded.

Public Class Methods

new(key, target, args, loader) click to toggle source
# File lib/dio/load_context.rb, line 14
def initialize(key, target, args, loader)
  @key = key
  @target = target
  @args = args
  @loader = loader
end

Public Instance Methods

load(*args) click to toggle source

Loads a dependency. You can omit arguments because the LoadContext instance already has arguments for loading.

@param args [Array] @return [Object] The dependency object.

# File lib/dio/load_context.rb, line 26
def load(*args)
  next_args = args.any? ? args : @args
  @loader.call(@key, *next_args)
end