-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class MinterState < ActiveRecord::Base | ||
validates :namespace, presence: true, uniqueness: true | ||
validates :template, presence: true | ||
validates :template, format: { with: Object.const_get('Noid::Template::VALID_PATTERN'), message: 'value fails regex' } | ||
|
||
# @return [Hash] options for Noid::Minter.new | ||
# * template [String] setting the identifier pattern | ||
# * seq [Integer] reflecting minter position in sequence | ||
# * counters [Array{Hash}] "buckets" each with :current and :max values | ||
# * rand [Object] random number generator object | ||
def noid_options | ||
Rails.logger.debug(" | ||
app/model/minter_state.rb is a placeholder for active_fedora-noid-2.0.0.beta1/app/models/minter_state.rb | ||
See: https://github.com/projecthydra-labs/active_fedora-noid/issues/29 | ||
Once active_fedora-noid-2.0.0 is out of beta, and CurationConcerns no longer requires it, | ||
remove this file. | ||
(This isn't actually used by heliotrope at all, it's just here to stop an initialization error in production) | ||
See #292 | ||
") | ||
return nil unless template | ||
opts = { | ||
template: template, | ||
seq: seq | ||
} | ||
opts[:counters] = JSON.parse(counters, symbolize_names: true) if counters | ||
opts[:rand] = Marshal.load(random) if random | ||
opts | ||
end | ||
end |