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.



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

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

Class Method Details

.append(value, chain) ⇒ Object



430
431
432
# File 'lib/rake.rb', line 430

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

Instance Method Details

#append(value) ⇒ Object



419
420
421
422
423
424
# File 'lib/rake.rb', line 419

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)


415
416
417
# File 'lib/rake.rb', line 415

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

#to_sObject



426
427
428
# File 'lib/rake.rb', line 426

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