Class: Consist::Recipe
- Inherits:
-
Object
- Object
- Consist::Recipe
- Defined in:
- lib/consist/recipe.rb
Instance Method Summary collapse
- #description(description = nil) ⇒ Object
-
#initialize(_id = nil, &definition) ⇒ Recipe
constructor
A new instance of Recipe.
- #name(name = nil) ⇒ Object
- #step(step_name, &block) ⇒ Object
- #steps(&block) ⇒ Object
- #user(user = nil) ⇒ Object
Constructor Details
#initialize(_id = nil, &definition) ⇒ Recipe
Returns a new instance of Recipe.
5 6 7 8 |
# File 'lib/consist/recipe.rb', line 5 def initialize(_id = nil, &definition) @steps = [] instance_eval(&definition) end |
Instance Method Details
#description(description = nil) ⇒ Object
15 16 17 18 |
# File 'lib/consist/recipe.rb', line 15 def description(description = nil) @description = description if description @description end |
#name(name = nil) ⇒ Object
10 11 12 13 |
# File 'lib/consist/recipe.rb', line 10 def name(name = nil) @name = name if name @name end |
#step(step_name, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/consist/recipe.rb', line 30 def step(step_name, &block) if block @steps << Step.new(id: step_name, &block) return end target_path = File.join("../../", "steps", step_name.to_s, "step.rb") step_path = File.(target_path, __FILE__) step_content = File.read(step_path) @steps << Step.new(id: step_name) { instance_eval(step_content) } end |
#steps(&block) ⇒ Object
25 26 27 28 |
# File 'lib/consist/recipe.rb', line 25 def steps(&block) instance_eval(&block) if block @steps end |
#user(user = nil) ⇒ Object
20 21 22 23 |
# File 'lib/consist/recipe.rb', line 20 def user(user = nil) @user = user if @user @user end |