class Nasty::Lazy

Public Class Methods

bind_factory(&block) click to toggle source
# File lib/nasty/lazy.rb, line 14
def bind_factory(&block)
  @@factory = block
end
load(key, factory = @@factory) click to toggle source
# File lib/nasty/lazy.rb, line 18
def load(key, factory = @@factory)
  Lazy.new(factory, key)
end
new(factory = ->(key) { key.new } click to toggle source
# File lib/nasty/lazy.rb, line 3
def initialize(factory = ->(key) { key.new }, *arguments)
  @factory = factory
  @arguments = arguments
end

Public Instance Methods

method_missing(name, *args, &block) click to toggle source
# File lib/nasty/lazy.rb, line 8
def method_missing(name, *args, &block)
  @target ||= @factory.call(*@arguments)
  @target.send(name, args, &block)
end