Module: Degect

Defined in:
lib/degect.rb,
lib/degect/degect.rb,
lib/degect/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#dependency(name, &blk) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/degect/degect.rb', line 2

def dependency(name, &blk)
  attr_writer name

  define_method(name) do
    ivar_name = "@#{name}"
    instance_variable_get(ivar_name) ||
      instance_variable_set(ivar_name, self.instance_exec(&blk))
  end
end