Sha256: b74109d96e3d8ce3a6418a43ef9bb3509c5edb4bc34d6536119215cd05690fa4

Contents?: true

Size: 981 Bytes

Versions: 20

Compression:

Stored size: 981 Bytes

Contents

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

      included do
        attr_reader :identifiers
        dump :identifiers
      end

      def initialize(*args)
        @identifiers = IdentifierList.new
        super
      end

      # Sets the identifiers.
      #
      # @param [Array] identifiers a list of identifiers
      def identifiers=(identifiers)
        @identifiers = IdentifierList.new(symbolize_keys(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.present?
          @identifiers << data
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
pupa-0.2.4 lib/pupa/models/concerns/identifiable.rb
pupa-0.2.3 lib/pupa/models/concerns/identifiable.rb
pupa-0.2.2 lib/pupa/models/concerns/identifiable.rb
pupa-0.2.1 lib/pupa/models/concerns/identifiable.rb
pupa-0.2.0 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.11 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.10 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.9 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.8 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.7 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.6 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.5 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.4 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.3 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.2 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.1 lib/pupa/models/concerns/identifiable.rb
pupa-0.1.0 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.13 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.12 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.11 lib/pupa/models/concerns/identifiable.rb