class ViewModel::ActiveRecord::UpdateContext::ReleasePool

def claim_from_pool(key)

def claim_from_pool(key)
  if (entry = @released_viewmodels.delete(key))
    entry.claimed!
    entry.viewmodel
  end
end

def include?(key)

def include?(key)
  @released_viewmodels.has_key?(key)
end

def initialize

def initialize
  # hash of { ViewModel::Reference => ReleaseEntry } for models
  # that have been released by nodes we've already visited
  @released_viewmodels = {}
end

def release_all!

def release_all!
  @released_viewmodels.each_value(&:release!)
end

def release_to_pool(viewmodel, association_data)

def release_to_pool(viewmodel, association_data)
  @released_viewmodels[viewmodel.to_reference] =
    ReleaseEntry.new(viewmodel, association_data)
end