Class: Eymiha::ForwardReference

Inherits:
Object
  • Object
show all
Defined in:
lib/eymiha/util/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.



147
148
149
150
151
152
# File 'lib/eymiha/util/forward_referencing.rb', line 147

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.



143
144
145
# File 'lib/eymiha/util/forward_referencing.rb', line 143

def context
  @context
end

#continuationObject (readonly)

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



135
136
137
# File 'lib/eymiha/util/forward_referencing.rb', line 135

def continuation
  @continuation
end

#dependencyObject

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



139
140
141
# File 'lib/eymiha/util/forward_referencing.rb', line 139

def dependency
  @dependency
end

Instance Method Details

#to_sObject

Returns a string indicating the current state of the ForwardReference.



155
156
157
# File 'lib/eymiha/util/forward_referencing.rb', line 155

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