Class: Rake::InvocationChain

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

Overview

InvocationChain tracks the chain of task invocations to detect circular dependencies.

Defined Under Namespace

Classes: EmptyInvocationChain

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, tail) ⇒ InvocationChain

Returns a new instance of InvocationChain.



391
392
393
394
# File 'lib/rake.rb', line 391

def initialize(value, tail)
  @value = value
  @tail = tail
end

Class Method Details

.append(value, chain) ⇒ Object



411
412
413
# File 'lib/rake.rb', line 411

def self.append(value, chain)
  chain.append(value)
end

Instance Method Details

#append(value) ⇒ Object



400
401
402
403
404
405
# File 'lib/rake.rb', line 400

def append(value)
  if member?(value)
    fail RuntimeError, "Circular dependency detected: #{to_s} => #{value}"
  end
  self.class.new(value, self)
end

#member?(obj) ⇒ Boolean

Returns:

  • (Boolean)


396
397
398
# File 'lib/rake.rb', line 396

def member?(obj)
  @value == obj || @tail.member?(obj)
end

#to_sObject



407
408
409
# File 'lib/rake.rb', line 407

def to_s
  "#{prefix}#{@value}"
end