class ActiveFedora::Noid::Minter::Base
Public Class Methods
new(template = default_template)
click to toggle source
@param template [#to_s] a NOID template @see Noid::Template
Calls superclass method
# File lib/active_fedora/noid/minter/base.rb, line 12 def initialize(template = default_template) super(template: template.to_s) end
Public Instance Methods
mint()
click to toggle source
Sychronously mint a new identifier. Guarantees the ID is not already reserved in ActiveFedora
.
@return [String] the minted identifier
# File lib/active_fedora/noid/minter/base.rb, line 20 def mint Mutex.new.synchronize do loop do pid = next_id return pid unless ActiveFedora::Base.exists?(pid) || ActiveFedora::Base.gone?(pid) end end end
read()
click to toggle source
@return [Hash{Symbol => String, Object}] representation of the current minter state
# File lib/active_fedora/noid/minter/base.rb, line 31 def read raise NotImplementedError, 'Implement #read in child class' end
write!(_)
click to toggle source
Updates the minter state to that of the `minter` parameter.
@param minter [Minter::Base] @return [void]
# File lib/active_fedora/noid/minter/base.rb, line 40 def write!(_) raise NotImplementedError, 'Implement #write! in child class' end
Protected Instance Methods
default_template()
click to toggle source
@return [#to_s] the default template for this
# File lib/active_fedora/noid/minter/base.rb, line 48 def default_template ActiveFedora::Noid.config.template end
next_id()
click to toggle source
@return [String] a new identifier
# File lib/active_fedora/noid/minter/base.rb, line 54 def next_id raise NotImplementedError, 'Implement #next_id in child class' end