Sha256: c56601a01758c0f3019405c9f5d081ec883d8ec9a988e8e7102b34a969d8e646

Contents?: true

Size: 837 Bytes

Versions: 76

Compression:

Stored size: 837 Bytes

Contents

module ActiveFedora
  # Create model classifiers for resources or solr documents
  class DefaultModelMapper
    attr_reader :classifier_class, :solr_field, :predicate

    def initialize(classifier_class: ActiveFedora::ModelClassifier, solr_field: ActiveFedora::QueryResultBuilder::HAS_MODEL_SOLR_FIELD, predicate: ActiveFedora::RDF::Fcrepo::Model.hasModel)
      @classifier_class = classifier_class
      @solr_field = solr_field
      @predicate = predicate
    end

    def classifier(resource)
      models = if resource.respond_to? :graph
                 resource.graph.query([nil, predicate, nil]).map { |rg| rg.object.to_s }
               elsif resource.respond_to? :[]
                 resource[solr_field] || []
               else
                 []
               end

      classifier_class.new(models)
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
active-fedora-15.0.1 lib/active_fedora/default_model_mapper.rb
active-fedora-15.0.0 lib/active_fedora/default_model_mapper.rb
active-fedora-14.0.1 lib/active_fedora/default_model_mapper.rb
active-fedora-14.0.0 lib/active_fedora/default_model_mapper.rb
active-fedora-13.3.0 lib/active_fedora/default_model_mapper.rb
active-fedora-12.2.4 lib/active_fedora/default_model_mapper.rb
active-fedora-13.2.7 lib/active_fedora/default_model_mapper.rb
active-fedora-13.2.5 lib/active_fedora/default_model_mapper.rb
active-fedora-13.2.4 lib/active_fedora/default_model_mapper.rb
active-fedora-12.2.3 lib/active_fedora/default_model_mapper.rb
active-fedora-13.2.3 lib/active_fedora/default_model_mapper.rb
active-fedora-13.2.2 lib/active_fedora/default_model_mapper.rb
active-fedora-13.2.0 lib/active_fedora/default_model_mapper.rb
active-fedora-13.1.3 lib/active_fedora/default_model_mapper.rb
active-fedora-11.5.6 lib/active_fedora/default_model_mapper.rb
active-fedora-12.2.2 lib/active_fedora/default_model_mapper.rb
active-fedora-11.2.1 lib/active_fedora/default_model_mapper.rb
active-fedora-12.2.1 lib/active_fedora/default_model_mapper.rb
active-fedora-12.0.3 lib/active_fedora/default_model_mapper.rb
active-fedora-11.5.5 lib/active_fedora/default_model_mapper.rb