module ActiveFedora::Model::ClassMethods
def attribute_get(name)
def attribute_get(name) #instance_variable_get(properties[":#{name}"].instance_variable_name) instance_variable_get("@#{name}") end
def attribute_set(name, value)
def attribute_set(name, value) instance_variable_set("@#{name}", value) end
def find(args)
Returns an Array of objects of the Class that +find+ is being
Takes :all or a pid as arguments
def find(args) if args == :all escaped_class_name = self.name.gsub(/(:)/, '\\:') q = "active_fedora_model_s:#{escaped_class_name}" elsif args.class == String escaped_id = args.gsub(/(:)/, '\\:') q = "#{SOLR_DOCUMENT_ID}:#{escaped_id}" end hits = SolrService.instance.conn.query(q).hits results = hits.map do |hit| obj = Fedora::Repository.instance.find_model(hit[SOLR_DOCUMENT_ID], self) #obj.inner_object.new_object = false #return obj end results.first end
def find_by_solr(query, args={})
Args is an options hash, which is passed into the SolrService
objects, but rather an array of SolrResults.
Note that this method does _not_ return ActiveFedora::Model
a pid based search (id:query).
by Solr). If the query is any other string, this method simply does
of self.type (based on active_fedora_model_s as indexed
If query is :all, this method will query Solr for all instances
def find_by_solr(query, args={}) if query == :all escaped_class_name = self.name.gsub(/(:)/, '\\:') SolrService.instance.conn.query("active_fedora_model_s:#{escaped_class_name}", args) elsif query.class == String escaped_id = query.gsub(/(:)/, '\\:') SolrService.instance.conn.query("#{SOLR_DOCUMENT_ID}:#{escaped_id}", args) end end
def load_instance(pid)
ActiveFedora will try to parse the results into the current type
pass an pid into this method, regardless of Fedora model type, and
Load an instance with the following pid. Note that you can actually
def load_instance(pid) Fedora::Repository.instance.find_model(pid, self) end
def solr_search(query, args={})
def solr_search(query, args={}) SolrService.instance.conn.query(query, args) end