Sha256: fbd86b5d4ae88801f8d0f2caceeb9575d60dc024fe75a64f191038d43895dc33

Contents?: true

Size: 961 Bytes

Versions: 33

Compression:

Stored size: 961 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
      deprecation_deprecate :human_readable_type= => 'human_readable_type is deprecated. ' \
        'Set the i18n key for activefedora.models.#{model_name.i18n_key} instead. ' \
        'This will be removed in Hyrax 3'
    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

33 entries across 33 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.9.5 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.9.4 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.9.3 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.9.2 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.9.1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.9.0 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.8.0 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.7.2 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.7.1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.7.0 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.6.0 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.5.1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.5.0 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.4.1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-3.0.0.pre.beta1 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.4.0 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.3.3 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.3.2 app/models/concerns/hyrax/human_readable_type.rb
hyrax-2.3.1 app/models/concerns/hyrax/human_readable_type.rb