Class: HDL::Dependency
- Inherits:
-
Object
- Object
- HDL::Dependency
- Defined in:
- lib/hdl/dependency.rb
Class Method Summary collapse
- .all ⇒ Object
-
.create(dependee, dependent) ⇒ Object
dependee depends on dependent.
-
.dependees_for(dependent) ⇒ Object
What depends on the dependent?.
-
.dependents_for(dependee) ⇒ Object
What does the dependee depend on?.
- .where(filter = {}) ⇒ Object
Class Method Details
.all ⇒ Object
11 12 13 |
# File 'lib/hdl/dependency.rb', line 11 def all set end |
.create(dependee, dependent) ⇒ Object
dependee depends on dependent
6 7 8 9 |
# File 'lib/hdl/dependency.rb', line 6 def create(dependee, dependent) check_for_cycles!(dependee, dependent) set << { dependee => dependent } end |
.dependees_for(dependent) ⇒ Object
What depends on the dependent?
36 37 38 |
# File 'lib/hdl/dependency.rb', line 36 def dependees_for(dependent) recursive_ancestors_for(dependent, :dependent, :keys) end |
.dependents_for(dependee) ⇒ Object
What does the dependee depend on?
31 32 33 |
# File 'lib/hdl/dependency.rb', line 31 def dependents_for(dependee) recursive_ancestors_for(dependee, :dependee, :values) end |
.where(filter = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hdl/dependency.rb', line 15 def where(filter = {}) scope = all if (f = filter[:dependee]) scope = scope.select { |h| h.keys.first == f } end if (f = filter[:dependent]) scope = scope.select { |h| h.values.first == f } end scope end |