Module: Pupa::Concerns::Identifiable

Extended by:
ActiveSupport::Concern
Included in:
Organization, Person
Defined in:
lib/pupa/models/concerns/identifiable.rb

Overview

Adds the Popolo identifiers property to a model.

Instance Method Summary collapse

Instance Method Details

#add_identifier(identifier, scheme: nil) ⇒ Object

Adds an issued identifier.

Parameters:

  • identifier (String)

    an issued identifier, e.g. a DUNS number

  • scheme (String) (defaults to: nil)

    an identifier scheme, e.g. DUNS



28
29
30
31
32
33
34
35
36
# 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) ⇒ Object

Sets the identifiers.

Parameters:

  • identifiers (Array)

    a list of identifiers



20
21
22
# File 'lib/pupa/models/concerns/identifiable.rb', line 20

def identifiers=(identifiers)
  @identifiers = IdentifierList.new(symbolize_keys(identifiers))
end

#initialize(*args) ⇒ Object



12
13
14
15
# File 'lib/pupa/models/concerns/identifiable.rb', line 12

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