Class: ForwardReference
- Inherits:
-
Object
- Object
- ForwardReference
- 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
-
#context ⇒ Object
Holds an arbitrary object that holds context that can be re-established to help resolve the forward reference.
-
#continuation ⇒ Object
readonly
Holds the place to jump back to for attempting to resolve a forward reference.
-
#dependency ⇒ Object
Holds an arbitrary object that indicates why the forward reference occurred.
Instance Method Summary collapse
-
#initialize(dependency = nil, context = nil) ⇒ ForwardReference
constructor
Returns a new instance with a valid continuation, the given dependency and contextual information.
-
#to_s ⇒ Object
Returns a string indicating the current state of the ForwardReference.
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
#context ⇒ Object
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 |
#continuation ⇒ Object (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 |
#dependency ⇒ Object
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_s ⇒ Object
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 |