Module: RailsWizard::Recipes
- Defined in:
- lib/rails_wizard/recipes.rb
Constant Summary collapse
- @@categories =
{}
- @@list =
{}
Class Method Summary collapse
- .[](key) ⇒ Object
- .add(recipe) ⇒ Object
- .categories ⇒ Object
- .for(category) ⇒ Object
- .list ⇒ Object
- .list_classes ⇒ Object
- .remove_from_category(category, recipe) ⇒ Object
Class Method Details
.[](key) ⇒ Object
14 15 16 |
# File 'lib/rails_wizard/recipes.rb', line 14 def self.[](key) @@list[key.to_s] end |
.add(recipe) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/rails_wizard/recipes.rb', line 6 def self.add(recipe) RailsWizard::Recipes.const_set ActiveSupport::Inflector.camelize(recipe.key), recipe @@list[recipe.key] = recipe (@@categories[recipe.category.to_s] ||= []) << recipe.key @@categories[recipe.category.to_s].uniq! recipe end |
.categories ⇒ Object
26 27 28 |
# File 'lib/rails_wizard/recipes.rb', line 26 def self.categories @@categories.keys.sort end |
.for(category) ⇒ Object
30 31 32 |
# File 'lib/rails_wizard/recipes.rb', line 30 def self.for(category) (@@categories[category.to_s] || []).sort end |
.list ⇒ Object
18 19 20 |
# File 'lib/rails_wizard/recipes.rb', line 18 def self.list @@list.keys.sort end |
.list_classes ⇒ Object
22 23 24 |
# File 'lib/rails_wizard/recipes.rb', line 22 def self.list_classes @@list.values.sort_by{|c| c.key} end |
.remove_from_category(category, recipe) ⇒ Object
34 35 36 |
# File 'lib/rails_wizard/recipes.rb', line 34 def self.remove_from_category(category, recipe) (@@categories[category.to_s] ||= []).delete(recipe.key) end |