Class: Playmo::Recipe::Recipe
- Defined in:
- lib/playmo/recipe/recipe.rb
Overview
Переименовать этот класс в DSL, и сделать отдельный класс Recipe, который будет предком DSL и от которого можно наследоваться для создания complex recipes У класса DSL будут еще свои методы типма build (?)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#application_name ⇒ Object
Returns the value of attribute application_name.
Instance Method Summary collapse
- #before_exit(&block) ⇒ Object
- #cook!(application_name) ⇒ Object
- #create_database(&block) ⇒ Object
- #generate(*args) ⇒ Object
-
#initialize ⇒ Recipe
constructor
A new instance of Recipe.
-
#install(&block) ⇒ Object
TODO: Move it into module.
- #migrate_database(&block) ⇒ Object
- #retrieve(*args) ⇒ Object
- #seed_database(&block) ⇒ Object
- #store(*args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Recipe
Returns a new instance of Recipe.
9 10 11 12 13 |
# File 'lib/playmo/recipe/recipe.rb', line 9 def initialize super @actions = [] end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
7 8 9 |
# File 'lib/playmo/recipe/recipe.rb', line 7 def actions @actions end |
#application_name ⇒ Object
Returns the value of attribute application_name.
7 8 9 |
# File 'lib/playmo/recipe/recipe.rb', line 7 def application_name @application_name end |
Instance Method Details
#before_exit(&block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/playmo/recipe/recipe.rb', line 37 def before_exit(&block) Event.events.listen(:before_exit) do # TODO: DRY this recipe_name = name self.class.class_eval do source_root "#{Playmo::ROOT}/recipes/templates/#{recipe_name}_recipe" end self.instance_eval &block end end |
#cook!(application_name) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/playmo/recipe/recipe.rb', line 93 def cook!(application_name) self.destination_root = application_name self.application_name = application_name actions.each do |action| action.call end end |
#create_database(&block) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/playmo/recipe/recipe.rb', line 50 def create_database(&block) Event.events.listen(:create_database) do # TODO: DRY this recipe_name = name self.class.class_eval do source_root "#{Playmo::ROOT}/recipes/templates/#{recipe_name}_recipe" end self.instance_eval &block end end |
#generate(*args) ⇒ Object
89 90 91 |
# File 'lib/playmo/recipe/recipe.rb', line 89 def generate(*args) install { super(*args) } end |
#install(&block) ⇒ Object
TODO: Move it into module
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/playmo/recipe/recipe.rb', line 24 def install(&block) Event.events.listen(:install) do # TODO: DRY this recipe_name = name self.class.class_eval do source_root "#{Playmo::ROOT}/recipes/templates/#{recipe_name}_recipe" end self.instance_eval &block end end |
#migrate_database(&block) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/playmo/recipe/recipe.rb', line 63 def migrate_database(&block) Event.events.listen(:migrate_database) do # TODO: DRY this recipe_name = name self.class.class_eval do source_root "#{Playmo::ROOT}/recipes/templates/#{recipe_name}_recipe" end self.instance_eval &block end end |
#retrieve(*args) ⇒ Object
19 20 21 |
# File 'lib/playmo/recipe/recipe.rb', line 19 def retrieve(*args) Options.instance.get(*args) end |
#seed_database(&block) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/playmo/recipe/recipe.rb', line 76 def seed_database(&block) Event.events.listen(:seed_database) do # TODO: DRY this recipe_name = name self.class.class_eval do source_root "#{Playmo::ROOT}/recipes/templates/#{recipe_name}_recipe" end self.instance_eval &block end end |
#store(*args) ⇒ Object
15 16 17 |
# File 'lib/playmo/recipe/recipe.rb', line 15 def store(*args) Options.instance.set(*args) end |
#to_s ⇒ Object
102 103 104 |
# File 'lib/playmo/recipe/recipe.rb', line 102 def to_s name end |