Sha256: a5fd6cbab7f01cbd9af7df04cf69ffbdce41aad41658e4db8567e53daf7fd4a5

Contents?: true

Size: 844 Bytes

Versions: 3

Compression:

Stored size: 844 Bytes

Contents

module Pupa
  module Concerns
    # Adds the Popolo `identifiers` property to a model.
    module Identifiable
      extend ActiveSupport::Concern

      included do
        attr_reader :identifiers
      end

      # Sets the identifiers.
      #
      # @param [Array] identifiers a list of identifiers
      def identifiers=(identifiers)
        @identifiers = IdentifierList.new(identifiers)
      end

      # Adds an issued identifier.
      #
      # @param [String] identifier an issued identifier, e.g. a DUNS number
      # @param [String] scheme an identifier scheme, e.g. DUNS
      def add_identifier(identifier, scheme: nil)
        data = {identifier: identifier}
        if scheme
          data[:scheme] = scheme
        end
        if identifier
          (@identifiers ||= []) << data
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pupa-0.0.8 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.7 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.6 lib/pupa/models/concerns/identifiable.rb