Module: Watchmaker::Learner::ClassMethods
- Defined in:
- lib/watchmaker/learner.rb
Instance Method Summary collapse
-
#define(name, dependencies = {}, &block) ⇒ Object
(also: #learn)
Learn a profile by taking explicit dependencies.
-
#name_and_dependencies_from_dependency_hash(dependencies) ⇒ Object
Get the profile name out of a dependency hash.
Instance Method Details
#define(name, dependencies = {}, &block) ⇒ Object Also known as: learn
Learn a profile by taking explicit dependencies.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/watchmaker/learner.rb', line 11 def define(name, dependencies = {}, &block) if name.is_a?(Hash) # Convert the hash into a profile name and a list of # dependencies that's either a hash of nested classes or # array. # name, dependencies = name_and_dependencies_from_dependency_hash(name) # Specifically store these as abstract dependencies. # dependencies = { :abstract => dependencies } end Configuration.learn(name, dependencies, &block) end |
#name_and_dependencies_from_dependency_hash(dependencies) ⇒ Object
Get the profile name out of a dependency hash.
35 36 37 38 |
# File 'lib/watchmaker/learner.rb', line 35 def name_and_dependencies_from_dependency_hash(dependencies) name = dependencies.keys.first [name, dependencies[name]] end |