module Pupa::Concerns::Identifiable

Adds the Popolo ‘identifiers` property to a model.

Attributes

identifiers[R]

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/pupa/models/concerns/identifiable.rb, line 12
def initialize(*args)
  @identifiers = IdentifierList.new
  super
end

Public Instance Methods

add_identifier(identifier, scheme: nil) click to toggle source

Adds an issued identifier.

@param [String] identifier an issued identifier, e.g. a DUNS number @param [String] scheme an identifier scheme, e.g. DUNS

# File lib/pupa/models/concerns/identifiable.rb, line 28
def add_identifier(identifier, scheme: nil)
  data = {identifier: identifier}
  if scheme
    data[:scheme] = scheme
  end
  if identifier.present?
    @identifiers << data
  end
end
identifiers=(identifiers) click to toggle source

Sets the identifiers.

@param [Array] identifiers a list of identifiers

# File lib/pupa/models/concerns/identifiable.rb, line 20
def identifiers=(identifiers)
  @identifiers = IdentifierList.new(symbolize_keys(identifiers))
end