def replacer
        lambda do |resource_id, graph|
          url = ActiveFedora::Base.id_to_uri(resource_id)
          klass = graph.query([:s, ActiveFedora::RDF::Fcrepo::Model.hasModel, :o]).first.object.to_s.constantize

          # if the subject URL matches
          if graph.query([RDF::URI(url), ActiveFedora::RDF::Fcrepo::Model.hasModel, nil]).first
            subject_replacer(klass, resource_id)
          elsif resource_id.start_with? solr_document.id
            subresource_replacer(resource_id, klass)
          else
            object_replacer(resource_id, graph)
          end
        end
      end
def replacer
        lambda do |resource_id, graph|
          url = ActiveFedora::Base.id_to_uri(resource_id)
          klass = graph.query([:s, ActiveFedora::RDF::Fcrepo::Model.hasModel, :o]).first.object.to_s.constantize

          # if the subject URL matches
          if graph.query([RDF::URI(url), ActiveFedora::RDF::Fcrepo::Model.hasModel, nil]).first
            subject_replacer(klass, resource_id)
          elsif resource_id.start_with? solr_document.id
            subresource_replacer(resource_id, klass)
          else
            object_replacer(resource_id, graph)
          end
        end
      end
This method is called once for each statement in the graph.