Class: FPM::Cookery::Book
- Inherits:
-
Object
- Object
- FPM::Cookery::Book
- Includes:
- Singleton
- Defined in:
- lib/fpm/cookery/book.rb
Instance Method Summary collapse
- #add_recipe_class(klass) ⇒ Object
-
#initialize ⇒ Book
constructor
A new instance of Book.
-
#load_recipe(filename, &callback) ⇒ Object
Load the given file and instantiate an object.
Constructor Details
#initialize ⇒ Book
Returns a new instance of Book.
8 9 10 |
# File 'lib/fpm/cookery/book.rb', line 8 def initialize @recipe = nil end |
Instance Method Details
#add_recipe_class(klass) ⇒ Object
19 20 21 |
# File 'lib/fpm/cookery/book.rb', line 19 def add_recipe_class(klass) @recipe = klass end |
#load_recipe(filename, &callback) ⇒ Object
Load the given file and instantiate an object. Wrap the class in an anonymous module to avoid namespace cluttering. (see Kernel.load)
14 15 16 17 |
# File 'lib/fpm/cookery/book.rb', line 14 def load_recipe(filename, &callback) Kernel.load(filename, true) callback.call(@recipe.new(filename)) end |