class ActiveFedora::SolrHit

Attributes

document[R]

Public Class Methods

for(hit) click to toggle source
# File lib/active_fedora/solr_hit.rb, line 3
def self.for(hit)
  return hit if hit.is_a? ActiveFedora::SolrHit

  SolrHit.new(hit)
end
new(document) click to toggle source
Calls superclass method
# File lib/active_fedora/solr_hit.rb, line 23
def initialize(document)
  document = document.with_indifferent_access
  super
  @document = document
end

Public Instance Methods

__getobj__() click to toggle source
# File lib/active_fedora/solr_hit.rb, line 11
def __getobj__
  @document # return object we are delegating to, required
end
Also aliased as: static_config
__setobj__(obj) click to toggle source
# File lib/active_fedora/solr_hit.rb, line 17
def __setobj__(obj)
  @document = obj
end
id() click to toggle source
# File lib/active_fedora/solr_hit.rb, line 29
def id
  document[ActiveFedora.id_field]
end
model(opts = {}) click to toggle source
# File lib/active_fedora/solr_hit.rb, line 37
def model(opts = {})
  best_model_match = classifier.best_model(opts)
  ActiveFedora::Base.logger.warn "Could not find a model for #{id}, defaulting to ActiveFedora::Base" if best_model_match == ActiveFedora::Base
  best_model_match
end
model?(model_to_check) click to toggle source
# File lib/active_fedora/solr_hit.rb, line 43
def model?(model_to_check)
  models.any? do |model|
    model_to_check >= model
  end
end
rdf_uri() click to toggle source
# File lib/active_fedora/solr_hit.rb, line 33
def rdf_uri
  ::RDF::URI.new(ActiveFedora::Base.id_to_uri(id))
end
reify(opts = {}) click to toggle source
# File lib/active_fedora/solr_hit.rb, line 49
def reify(opts = {})
  model(opts).find(id, cast: true)
end
static_config()
Alias for: __getobj__

Private Instance Methods

classifier() click to toggle source
# File lib/active_fedora/solr_hit.rb, line 55
def classifier
  ActiveFedora.model_mapper.classifier(document)
end