Class: Playmo::Recipe

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/playmo/recipe.rb

Overview

Base class for all recipes

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#application_nameObject

Returns the value of attribute application_name.



6
7
8
# File 'lib/playmo/recipe.rb', line 6

def application_name
  @application_name
end

#question_instanceObject

Returns the value of attribute question_instance.



6
7
8
# File 'lib/playmo/recipe.rb', line 6

def question_instance
  @question_instance
end

#silentsObject

Returns the value of attribute silents.



6
7
8
# File 'lib/playmo/recipe.rb', line 6

def silents
  @silents
end

Instance Method Details

#cook!(application_name) ⇒ Object

Приготовление рецепта



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/playmo/recipe.rb', line 9

def cook!(application_name)
  self.destination_root = application_name
  self.application_name = application_name
  setup

  unless question_instance.nil?
    question_instance.set_caller(self)

    # Ask question
    question_instance.ask_question!

    # Ask for choice and make choice
    question_instance.choice.make_choice!
  end

  # Execute all silents
  unless silents.nil?
    silents.each do |silent|
      silent.set_caller(self)
      silent.execute!
    end
  end
end

#question(arg, &block) ⇒ Object



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

def question(arg, &block)
  @question_instance = Playmo::Question.new(arg, &block)
end

#retrieve(*args) ⇒ Object



46
47
48
# File 'lib/playmo/recipe.rb', line 46

def retrieve(*args)
  Options.instance.get(*args)
end

#silently(&block) ⇒ Object



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

def silently(&block)
  @silents ||= []
  @silents << Playmo::Silent.new(&block)
end

#store(*args) ⇒ Object



42
43
44
# File 'lib/playmo/recipe.rb', line 42

def store(*args)
  Options.instance.set(*args)
end