Class: VContainer::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/vcontainer/container.rb

Overview

A basic container implementation

Direct Known Subclasses

ContainerDsl

Instance Method Summary collapse

Instance Method Details

#can_provide?(what) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/vcontainer/container.rb', line 16

def can_provide?(what)
  provider_for(what) != nil
end

#provide(what) ⇒ Object



12
13
14
# File 'lib/vcontainer/container.rb', line 12

def provide(what)
  provider_for(what).build(what, self)
end

#provide_for_method(method) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/vcontainer/container.rb', line 20

def provide_for_method(method)
  params = method.parameters
  has_parameters = params[0]!=[:rest]
  if has_parameters
    provide_instances_for(params)
  else
    []
  end
end

#use(provider) ⇒ Object



8
9
10
# File 'lib/vcontainer/container.rb', line 8

def use(provider)
  providers << provider
end