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
An object representing 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.
13 14 15 |
# File 'lib/active_fedora/noid/minter/base.rb', line 13 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.
22 23 24 25 26 27 28 29 |
# File 'lib/active_fedora/noid/minter/base.rb', line 22 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
Returns an object representing the current minter state.
33 34 35 |
# File 'lib/active_fedora/noid/minter/base.rb', line 33 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.
43 44 45 |
# File 'lib/active_fedora/noid/minter/base.rb', line 43 def write!(_) raise NotImplementedError, 'Implement #write! in child class' end |