Class: Autodeps::Dependency
- Inherits:
-
Object
- Object
- Autodeps::Dependency
- Defined in:
- lib/autodeps/dependency.rb
Instance Attribute Summary collapse
-
#dependents ⇒ Object
Returns the value of attribute dependents.
Instance Method Summary collapse
- #changed ⇒ Object
- #depend(computation = Autodeps.current_computation) ⇒ Object
- #hasDependents ⇒ Object
-
#initialize ⇒ Dependency
constructor
A new instance of Dependency.
Constructor Details
#initialize ⇒ Dependency
Returns a new instance of Dependency.
4 5 6 |
# File 'lib/autodeps/dependency.rb', line 4 def initialize @dependents = ThreadSafe::Array.new end |
Instance Attribute Details
#dependents ⇒ Object
Returns the value of attribute dependents.
3 4 5 |
# File 'lib/autodeps/dependency.rb', line 3 def dependents @dependents end |
Instance Method Details
#changed ⇒ Object
25 26 27 28 29 |
# File 'lib/autodeps/dependency.rb', line 25 def changed @dependents.each do |computation| computation.invalidate end end |
#depend(computation = Autodeps.current_computation) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/autodeps/dependency.rb', line 7 def depend(computation = Autodeps.current_computation) if (!computation) return false if (!Autodeps.active) computation = Deps.current_computation; end if !@dependents.include?(computation) @dependents << computation computation.on_invalidate do @dependents.delete(computation) end return true else return false; end end |
#hasDependents ⇒ Object
31 32 33 |
# File 'lib/autodeps/dependency.rb', line 31 def hasDependents !@dependents.empty? end |