Class: Consist::Recipe

Inherits:
Object
  • Object
show all
Defined in:
lib/consist/recipe.rb

Instance Method Summary collapse

Constructor Details

#initialize(id = nil, &definition) ⇒ Recipe

Returns a new instance of Recipe.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/consist/recipe.rb', line 5

def initialize(id = nil, &definition)
  @steps = []
  @id = id

  if definition
    instance_eval(&definition)
  else
    contents = Consist::Resolver.new(pwd: Dir.pwd).resolve_artifact(type: :recipe, id:)
    instance_eval(contents)
  end
end

Instance Method Details

#description(description = nil) ⇒ Object



22
23
24
25
# File 'lib/consist/recipe.rb', line 22

def description(description = nil)
  @description = description if description
  @description
end

#name(name = nil) ⇒ Object



17
18
19
20
# File 'lib/consist/recipe.rb', line 17

def name(name = nil)
  @name = name if name
  @name
end

#step(id, &definition) ⇒ Object



37
38
39
# File 'lib/consist/recipe.rb', line 37

def step(id, &definition)
  @steps << Step.new(id:, &definition)
end

#steps(&definition) ⇒ Object



32
33
34
35
# File 'lib/consist/recipe.rb', line 32

def steps(&definition)
  instance_eval(&definition) if definition
  @steps
end

#user(user = nil) ⇒ Object



27
28
29
30
# File 'lib/consist/recipe.rb', line 27

def user(user = nil)
  @user = user if @user
  @user
end