Class: Noid::Rails::Minter::Base Abstract
- Inherits:
-
Minter
- Object
- Minter
- Noid::Rails::Minter::Base
- Defined in:
- lib/noid/rails/minter/base.rb
Overview
This class is abstract.
the base class for minters
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.
13 14 15 |
# File 'lib/noid/rails/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.
21 22 23 24 25 26 27 28 |
# File 'lib/noid/rails/minter/base.rb', line 21 def mint Mutex.new.synchronize do loop do pid = next_id return pid unless identifier_in_use?(pid) end end end |
#read ⇒ Hash{Symbol => String, Object}
Returns representation of the current minter state.
32 33 34 |
# File 'lib/noid/rails/minter/base.rb', line 32 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.
41 42 43 |
# File 'lib/noid/rails/minter/base.rb', line 41 def write!(_) raise NotImplementedError, 'Implement #write! in child class' end |