Class: ForwardReference

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

Overview

A ForwardReference holds a continuation and a dependency, the where and the why of forward referencing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency = nil, context = nil) ⇒ ForwardReference

Returns a new instance with a valid continuation, the given dependency and contextual information.



145
146
147
148
149
150
# File 'lib/forward_referencing.rb', line 145

def initialize(dependency=nil,context=nil)
  @continuation = nil
  @continuation = callcc{|cont| cont} while (@continuation == nil)
  @dependency = dependency
  @context = context
end

Instance Attribute Details

#contextObject

Holds an arbitrary object that holds context that can be re-established to help resolve the forward reference.



141
142
143
# File 'lib/forward_referencing.rb', line 141

def context
  @context
end

#continuationObject (readonly)

Holds the place to jump back to for attempting to resolve a forward reference.



133
134
135
# File 'lib/forward_referencing.rb', line 133

def continuation
  @continuation
end

#dependencyObject

Holds an arbitrary object that indicates why the forward reference occurred.



137
138
139
# File 'lib/forward_referencing.rb', line 137

def dependency
  @dependency
end

Instance Method Details

#to_sObject

Returns a string indicating the current state of the ForwardReference.



153
154
155
# File 'lib/forward_referencing.rb', line 153

def to_s
  "#{self_name}  dependency #{dependency}  #{continuation}"
end