Class: Rook::Oven
- Inherits:
-
Object
- Object
- Rook::Oven
- Defined in:
- lib/rook/recipe.rb
Overview
:nodoc:
Instance Method Summary collapse
- #bake(_kitchen) ⇒ Object
-
#initialize(recipe) ⇒ Oven
constructor
A new instance of Oven.
Methods included from Assertion
Constructor Details
#initialize(recipe) ⇒ Oven
Returns a new instance of Oven.
191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/rook/recipe.rb', line 191 def initialize(recipe) @recipe = recipe recipe.instance_variables.each do |name| value = recipe.instance_variable_get(name) instance_variable_set(name, value) end @ingred = @ingreds.first if @ingreds @coprod = @coprods.first if @coprods @byprod = @byprods.first if @byprods @topping = @toppings.first if @toppings end |
Instance Method Details
#bake(_kitchen) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/rook/recipe.rb', line 204 def bake(_kitchen) ## copy properties as instance variable _kitchen.property_names.each do |name| instance_variable_set("@#{name}", _kitchen.get_property(name)) end ## invoke @block or @method if @block self.instance_eval(&@block) elsif @method ## set variables as local vars @_vars = {} _code = [] _kitchen.parameter_names.each do |_name| @_vars[_name] = _kitchen.get_parameter(_name) _code << "#{_name}=@_vars['#{_name}'];" end @recipe.params.each do |_param| _name = _param['name'] if _name[-1] == ?* _name = _name[0, _name.length-1] _expr = _param['value'] _code << "#{_name}=(#{_expr});" else @_vars[_name] = _param['value'] _code << "#{_name}=@_vars['#{_name}'];" end end if @recipe.params _code << @method self.instance_eval(_code.join, @bookname, @linenum) end end |