Class: Playmo::Recipe::Dsl

Inherits:
Recipe show all
Defined in:
lib/playmo/recipe/dsl.rb

Instance Attribute Summary collapse

Attributes inherited from Recipe

#actions, #application_name

Instance Method Summary collapse

Methods inherited from Recipe

#before_exit, #cook!, #create_database, #generate, #install, #migrate_database, #retrieve, #seed_database, #store, #to_s

Constructor Details

#initialize(name, options, &block) ⇒ Dsl

Returns a new instance of Dsl.



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

def initialize(name, options, &block)
  super()

  raise 'Recipe name not specified!' unless name

  @name    = name
  @options = options

  instance_eval &block
end

Instance Attribute Details

#after(after) ⇒ Object

TODO: Сделать автолоадинг для зависимых рецептов



36
37
38
# File 'lib/playmo/recipe/dsl.rb', line 36

def after
  @after
end

#description(description = nil) ⇒ Object

Returns the value of attribute description.



4
5
6
# File 'lib/playmo/recipe/dsl.rb', line 4

def description
  @description
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/playmo/recipe/dsl.rb', line 4

def name
  @name
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/playmo/recipe/dsl.rb', line 4

def options
  @options
end

Instance Method Details

#ask(question, &block) ⇒ Object



27
28
29
# File 'lib/playmo/recipe/dsl.rb', line 27

def ask(question, &block)
  actions << lambda { Playmo::Question.new(self, question, :type => :ask, &block).to_s }
end

#question(question, &block) ⇒ Object

Если блок с агрументами - то поддерживается ввод данных пользователем



23
24
25
# File 'lib/playmo/recipe/dsl.rb', line 23

def question(question, &block)
  actions << lambda { Playmo::Question.new(self, question, :type => :question, &block).to_s }
end

#silently(&block) ⇒ Object



31
32
33
# File 'lib/playmo/recipe/dsl.rb', line 31

def silently(&block)
  actions << lambda { Playmo::Silent.new(self, &block) }
end