Class: Lyp::DependencyLeaf
- Inherits:
-
Object
- Object
- Lyp::DependencyLeaf
- Defined in:
- lib/lyp/resolver.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
Instance Method Summary collapse
- #add_dependency(name, spec) ⇒ Object
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(dependencies = {}) ⇒ DependencyLeaf
constructor
A new instance of DependencyLeaf.
- #resolve(opts = {}) ⇒ Object
Constructor Details
#initialize(dependencies = {}) ⇒ DependencyLeaf
Returns a new instance of DependencyLeaf.
27 28 29 |
# File 'lib/lyp/resolver.rb', line 27 def initialize(dependencies = {}) @dependencies = dependencies.inject({}) {|m, kv| m[kv[0].to_s] = kv[1]; m} end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
25 26 27 |
# File 'lib/lyp/resolver.rb', line 25 def dependencies @dependencies end |
Instance Method Details
#add_dependency(name, spec) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/lyp/resolver.rb', line 31 def add_dependency(name, spec) if @dependencies[name.to_s] && !spec.eql?(@dependencies[name.to_s]) DependencyResolver.error("Clause mismatch found in %s", spec.location) end @dependencies[name.to_s] = spec end |
#eql?(o) ⇒ Boolean
42 43 44 |
# File 'lib/lyp/resolver.rb', line 42 def eql?(o) @dependencies.eql?(o.dependencies) end |
#hash ⇒ Object
46 47 48 |
# File 'lib/lyp/resolver.rb', line 46 def hash @dependencies.hash end |
#resolve(opts = {}) ⇒ Object
38 39 40 |
# File 'lib/lyp/resolver.rb', line 38 def resolve(opts = {}) DependencyResolver.new(self, opts).resolve_tree end |