Module: Hypo::LifetimeFriendly

Included in:
Component, Instance
Defined in:
lib/hypo/lifetime_friendly.rb

Instance Method Summary collapse

Instance Method Details

#use_lifetime(name) ⇒ Object Also known as: using_lifetime



3
4
5
6
7
8
9
10
11
12
# File 'lib/hypo/lifetime_friendly.rb', line 3

def use_lifetime(name)
  unless @container.lifetimes.key? name
    raise ContainerError, "Lifetime with name \"#{name}\" is not registered"
  end

  @lifetime = @container.lifetimes[name]
  @lifetime.preload(self) if @lifetime.respond_to? :preload

  self
end