module ActiveFedora::SemanticNode::ClassMethods

def create_outbound_relationship_finders(name, predicate, opts = {})

def create_outbound_relationship_finders(name, predicate, opts = {})
  class_eval <<-END
  def #{name}(opts={})
    id_array = []
    if !outbound_relationships[#{predicate.inspect}].nil? 
      outbound_relationships[#{predicate.inspect}].each do |rel|
        id_array << rel.gsub("info:fedora/", "")
      end
    end
    if opts[:response_format] == :id_array
      return id_array
    else
      query = ActiveFedora::SolrService.construct_query_for_pids(id_array)
      solr_result = SolrService.instance.conn.query(query)
      if opts[:response_format] == :solr
        return solr_result
      else
        return ActiveFedora::SolrService.reify_solr_results(solr_result)
      end
    end
  end
  def #{name}_ids
    #{name}(:response_format => :id_array)
  end
  END
end