Sha256: a0e5f13e34173b746dbc606da27c3e572263ccd4d41fcda4e5c49ffb2e55536f

Contents?: true

Size: 1.43 KB

Versions: 21

Compression:

Stored size: 1.43 KB

Contents

module CurationConcerns
  module PresentsAttributes
    ##
    # Present the attribute as an HTML table row.
    #
    # @param [Hash] options
    # @option options [true, false] :catalog_search_link return a link to a catalog search for that text if true
    # @option options [String] :search_field If the method_name of the attribute is different than
    #   how the attribute name should appear on the search URL,
    #   you can explicitly set the URL's search field name
    # @option options [String] :label The default label for the field if no translation is found
    def attribute_to_html(field, options = {})
      unless respond_to?(field)
        Rails.logger.warn("#{self.class} attempted to render #{field}, but no method exists with that name.")
        return
      end
      AttributeRenderer.new(field, send(field), options).render
    end

    def permission_badge
      permission_badge_class.new(solr_document).render
    end

    def permission_badge_class
      PermissionBadge
    end

    def display_microdata?
      CurationConcerns.config.display_microdata
    end

    def microdata_type_to_html
      return "" unless display_microdata?
      value = I18n.t(microdata_type_key, default: CurationConcerns.config.microdata_default_type)
      " itemscope itemtype=\"#{value}\"".html_safe
    end

    private

      def microdata_type_key
        "curation_concerns.schema_org.resource_type.#{human_readable_type}"
      end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta1 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.14.0 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.14.0.pre4 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.14.0.pre3 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.14.0.pre2 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.14.0.pre1 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.13.1 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.13.0 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre9 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre8 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre7 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre6 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre5 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre4 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre3 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre2 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.12.0.pre1 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.11.0 app/presenters/curation_concerns/presents_attributes.rb
curation_concerns-0.11.0.rc1 app/presenters/curation_concerns/presents_attributes.rb