Module: Cheffish::WithPattern
- Included in:
- ChefRunData
- Defined in:
- lib/cheffish/with_pattern.rb
Instance Method Summary collapse
Instance Method Details
#with(symbol) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cheffish/with_pattern.rb', line 3 def with(symbol) class_eval " attr_accessor :current_\#{symbol}\n\n def with_\#{symbol}(value)\n old_value = self.current_\#{symbol}\n self.current_\#{symbol} = value\n if block_given?\n begin\n yield\n ensure\n self.current_\#{symbol} = old_value\n end\n end\n end\n" end |