Sha256: d1583371ae661a0e605c829de5d5499335d38f3b8026a33a43fdeb5ba551991d

Contents?: true

Size: 740 Bytes

Versions: 21

Compression:

Stored size: 740 Bytes

Contents

module Hyrax
  module HumanReadableType
    extend ActiveSupport::Concern

    module ClassMethods
      def human_readable_type
        default = @_human_readable_type || name.demodulize.titleize
        I18n.translate("activefedora.models.#{model_name.i18n_key}", default: default)
      end

      def human_readable_type=(val)
        @_human_readable_type = val
      end
    end

    def human_readable_type
      self.class.human_readable_type
    end

    def to_solr(solr_doc = {})
      super(solr_doc).tap do |doc|
        doc[Solrizer.solr_name('human_readable_type', :facetable)] = human_readable_type
        doc[Solrizer.solr_name('human_readable_type', :stored_searchable)] = human_readable_type
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hyrax-1.1.1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.3 app/models/concerns/hyrax/human_readable_type.rb
hyrax-1.1.0 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.2 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0.rc3 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0.rc2 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0.rc1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-1.0.5 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0.beta5 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0.beta4 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0.beta3 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0.beta2 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.0.0.beta1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-1.0.4 app/models/concerns/hyrax/human_readable_type.rb
hyrax-1.0.3 app/models/concerns/hyrax/human_readable_type.rb
hyrax-1.0.2 app/models/concerns/hyrax/human_readable_type.rb
hyrax-1.0.1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-1.0.0.rc2 app/models/concerns/hyrax/human_readable_type.rb