Sha256: 347915a0942a0fd294e8f0203b7f719af5987485560de233137549aafe73e1cf

Contents?: true

Size: 812 Bytes

Versions: 3

Compression:

Stored size: 812 Bytes

Contents

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
    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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_fedora-noid-2.0.0.beta3 app/models/minter_state.rb
active_fedora-noid-2.0.0.beta2 app/models/minter_state.rb
active_fedora-noid-2.0.0.beta1 app/models/minter_state.rb