Sha256: 71671dae446c8f215f702cbd47306c3f7f1d1f3447b925cb28d60ee63d19cf63

Contents?: true

Size: 649 Bytes

Versions: 5

Compression:

Stored size: 649 Bytes

Contents

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

      included do
        attr_accessor :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

5 entries across 5 versions & 1 rubygems

Version Path
pupa-0.0.5 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.4 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.3 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.2 lib/pupa/models/concerns/identifiable.rb
pupa-0.0.1 lib/pupa/models/concerns/identifiable.rb