Sha256: 23a01f61641656b1f26b37ef32918bbc4fee3187dc1149eccd8308d1965eff43

Contents?: true

Size: 702 Bytes

Versions: 7

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

module Arclight
  ##
  # Logic containing information about Solr_Ead "Parent"
  # https://github.com/awead/solr_ead/blob/8cf7ffaa66e0e4c9c0b12f5646d6c2e20984cd99/lib/solr_ead/behaviors.rb#L54-L57
  class Parent
    attr_reader :id, :label, :eadid, :level

    def initialize(id:, label:, eadid:, level:)
      @id = id
      @label = label
      @eadid = eadid
      @level = level
    end

    def collection?
      level == 'collection'
    end

    ##
    # Concatenates the eadid and the id, to return an "id" in the context of
    # Blacklight and Solr
    # @return [String]
    def global_id
      return id if eadid == id

      "#{eadid}#{id}"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arclight-1.0.1 app/models/arclight/parent.rb
arclight-1.0.0 app/models/arclight/parent.rb
arclight-1.0.0.beta6 app/models/arclight/parent.rb
arclight-1.0.0.beta4 app/models/arclight/parent.rb
arclight-1.0.0.beta3 app/models/arclight/parent.rb
arclight-1.0.0.beta2 app/models/arclight/parent.rb
arclight-1.0.0.beta1 app/models/arclight/parent.rb