Module: Hydra::Ezid::Identifiable

Extended by:
ActiveSupport::Concern
Defined in:
lib/hydra/ezid/identifiable.rb

Instance Method Summary collapse

Instance Method Details

#idify(*ary) ⇒ Object

TODO: This will be done by ezid gem, THROW AWAY



43
44
45
# File 'lib/hydra/ezid/identifiable.rb', line 43

def idify(*ary)
  "#{ary[0]}:/#{ary[1]}/#{ary[2]}#{ary[3]}"
end

#mint_arkObject



70
71
72
# File 'lib/hydra/ezid/identifiable.rb', line 70

def mint_ark
  mint_ezid(Hydra::Ezid.config(except_keys: :doi))
end

#mint_doiObject



66
67
68
# File 'lib/hydra/ezid/identifiable.rb', line 66

def mint_doi
  mint_ezid(Hydra::Ezid.config(except_keys: :ark))
end

#mint_ezid(conf = Hydra::Ezid.config) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/hydra/ezid/identifiable.rb', line 47

def mint_ezid(conf = Hydra::Ezid.config)
  raise Hydra::Ezid::MintError.new("Cannot mint EZID until object is saved") unless self.persisted?
  self.class.ezid_registry.each_pair do |scheme, opts|
    scheme_conf = conf.values.find { |subkeys| subkeys['scheme'] == scheme.to_s }
    next unless scheme_conf
    id = idify(scheme_conf['scheme'], scheme_conf['naa'], scheme_conf['shoulder'], self.pid)
    datastreams["#{opts[:datastream]}"].send("#{opts[:field]}=", id)
  end
  # TODO: When generate_ezid is ready, fix me with something like:
  #   session = ::Ezid::ApiSession.new(
  #     conf.doi.user,
  #     conf.doi.pass,
  #     conf.doi.scheme,
  #     conf.doi.naa
  #  )
  #  @ezid = session.generate_ezid(conf.doi.shoulder + self.pid)
  nil
end