Module: Garcon::Resource::LazyEval
- Extended by:
- ClassMethods
- Included in:
- Garcon::Resource
- Defined in:
- lib/garcon/chef/resource/lazy_eval.rb
Overview
Resource mixin to allow lazyily-evaluated defaults in resource attributes.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#set_or_return(symbol, arg, validation) ⇒ Object
Override the default set_or_return to support lazy evaluation of the default value.
Methods included from ClassMethods
Instance Method Details
#set_or_return(symbol, arg, validation) ⇒ Object
Override the default set_or_return to support lazy evaluation of the default value. This only actually matters when it is called from a class level context via #attributes.
57 58 59 60 61 62 63 |
# File 'lib/garcon/chef/resource/lazy_eval.rb', line 57 def set_or_return(symbol, arg, validation) if validation && validation[:default].is_a?(Chef::DelayedEvaluator) validation = validation.dup validation[:default] = instance_eval(&validation[:default]) end super(symbol, arg, validation) end |