Class: ActiveFedora::Noid::Minter::Base
- Inherits:
-
Noid::Minter
- Object
- Noid::Minter
- ActiveFedora::Noid::Minter::Base
- Defined in:
- lib/active_fedora/noid/minter/base.rb
Instance Method Summary collapse
-
#initialize(template = default_template) ⇒ Base
constructor
A new instance of Base.
-
#mint ⇒ String
Sychronously mint a new identifier.
-
#read ⇒ Hash{Symbol => String, Object}
Representation of the current minter state.
-
#write!(_) ⇒ void
Updates the minter state to that of the ‘minter` parameter.
Constructor Details
#initialize(template = default_template) ⇒ Base
Returns a new instance of Base.
12 13 14 |
# File 'lib/active_fedora/noid/minter/base.rb', line 12 def initialize(template = default_template) super(template: template.to_s) end |
Instance Method Details
#mint ⇒ String
Sychronously mint a new identifier. Guarantees the ID is not already reserved in ActiveFedora.
20 21 22 23 24 25 26 27 |
# 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 ⇒ Hash{Symbol => String, Object}
Returns representation of the current minter state.
31 32 33 |
# File 'lib/active_fedora/noid/minter/base.rb', line 31 def read raise NotImplementedError, 'Implement #read in child class' end |
#write!(_) ⇒ void
This method returns an undefined value.
Updates the minter state to that of the ‘minter` parameter.
40 41 42 |
# File 'lib/active_fedora/noid/minter/base.rb', line 40 def write!(_) raise NotImplementedError, 'Implement #write! in child class' end |