Class: Autodeps::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/autodeps/dependency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDependency

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

#dependentsObject

Returns the value of attribute dependents.



3
4
5
# File 'lib/autodeps/dependency.rb', line 3

def dependents
  @dependents
end

Instance Method Details

#changedObject



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

#hasDependentsObject



31
32
33
# File 'lib/autodeps/dependency.rb', line 31

def hasDependents
  !@dependents.empty?
end