Module: Let::ClassMethods
- Defined in:
- lib/let.rb
Instance Method Summary collapse
Instance Method Details
#let(var, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/let.rb', line 8 def let(var,&block) name = "@#{var}" self.class_eval do define_method(var) do if instance_variable_defined?(name) instance_variable_get(name) else val = self.instance_eval(&block) instance_variable_set(name,val) end end end end |