lib/forward_referencing.rb in eymiha_util-0.1.4 vs lib/forward_referencing.rb in eymiha_util-0.1.5
- old
+ new
@@ -14,11 +14,11 @@
attr_reader :forward_references
# To be called from the initializer of the includer, this sets up the forward
# reference capture and resolution mechanisms.
def start_forward_referencing
- @forward_references = []
+ forward_references_clear
@had_forward_reference_resolution = false
@forward_reference_resolver = nil
end
# To be called when a section of code that could contain a forward reference
@@ -48,11 +48,11 @@
# establish_forward_reference context method is called with the context that
# was provided at the time the forward reference was created to give the
# receiver a chance to reset any transcient infromation.
def resolve_forward_references
forward_references = @forward_references
- @forward_references = []
+ forward_references_clear
@had_forward_reference_resolution = false
if forward_references.size > 0
@forward_reference_resolver ||= callcc {|cont| cont} while
(@forward_reference_resolver == nil)
forward_reference = forward_references.shift
@@ -94,10 +94,15 @@
# Returns the number of unresolved forward references.
def forward_references_remaining
@forward_references.size
end
+ # Remove the remaining unresolved forward references.
+ def forward_references_clear
+ @forward_references = []
+ end
+
end
# A ForwardReferencer is simply a class-wrapper for the ForwardReferencing
# module. method have been shortened there is reduced potential for conflict
@@ -112,9 +117,10 @@
alias resolve resolve_forward_references
alias continue continue_forward_reference_resolution
alias dependencies forward_reference_dependencies
alias to_s forward_references_to_s
alias remaining forward_references_remaining
+ alias clear forward_references_clear
end
# A ForwardReference holds a continuation and a dependency, the where and