Dependency
Synopsis
This module is included in Object and allows methods to be given prerequisite dependencies, i.e. methods that must be run before they are.
A dependency will only ever be run once per method call.
include MethodDependency def one; @str << '1'; end def two; @str << '2'; end def show; @str ; end depend :show => [ :x, :y ] show #=> '12'
You can add this functionality to the whole system by simply including it at the toplevel.
Author
- Thomas Sawyer
Notes
- The included call back does a comparison to Object. This is a bit of a hack b/c there is actually no way to check if it is the toplevel —a flaw w/ Ruby‘s toplevel proxy.
Todo
- Need to be more flexible with passing arguments to dependency methods.
- Avoid global variable. How?
Copying
Copyright (c) 2006 Thomas Sawyer Ruby License This module is free software. You may use, modify, and/or redistribute this software under the same terms as Ruby. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Required Files
- facets/hash/to_h