Sha256: d056ff8f95b73f9b13de6edbf654a279ef605cfba7a53d33ef24e4364855ed99

Contents?: true

Size: 837 Bytes

Versions: 8

Compression:

Stored size: 837 Bytes

Contents

module Hydra::ModelMixins
  module SolrDocumentExtension
    def document_type display_type = CatalogController.blacklight_config.show.display_type
      type = self.fetch(:medium_t, nil)

      type ||= self.fetch(display_type, nil) if display_type

      type.first.to_s.gsub("info:fedora/afmodel:","").gsub("Hydrangea","").gsub(/^Generic/,"")
    end

    def get_person_from_role(role, opts={})
      i = 0
      while i < 10
        persons_roles = self["person_#{i}_role_t"].map{|w|w.strip.downcase} unless self["person_#{i}_role_t"].nil?
        if persons_roles and persons_roles.include?(role.downcase)
          return {:first=>self["person_#{i}_first_name_t"], :last=>self["person_#{i}_last_name_t"]}
        end
        i += 1
      end
    end
  end
end

SolrDocument.use_extension Hydra::ModelMixins::SolrDocumentExtension

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
hydra-head-4.1.3 lib/hydra/model_mixins/solr_document_extension.rb
hydra-head-4.1.2 lib/hydra/model_mixins/solr_document_extension.rb
hydra-core-5.0.0.pre4 lib/hydra/model_mixins/solr_document_extension.rb
hydra-core-5.0.0.pre3 lib/hydra/model_mixins/solr_document_extension.rb
hydra-core-5.0.0.pre2 lib/hydra/model_mixins/solr_document_extension.rb
hydra-core-5.0.0.pre1 lib/hydra/model_mixins/solr_document_extension.rb
hydra-head-4.1.1 lib/hydra/model_mixins/solr_document_extension.rb
hydra-head-4.1.0 lib/hydra/model_mixins/solr_document_extension.rb