Sha256: b3a488e11eb1169d31ac3123cab483e5a9d7d72d4e80dc982af6668291692c34

Contents?: true

Size: 441 Bytes

Versions: 5

Compression:

Stored size: 441 Bytes

Contents

require 'securerandom'

module CertificateAuthority
  class SerialNumber
    include Validations
    include Revocable

    attr_accessor :number

    def validate
      if self.number.nil?
        errors.add :number, "must not be empty"
      elsif self.number.to_i <= 0
        errors.add :number, "must be greater than zero"
      end
    end

    def initialize
      self.number = SecureRandom.random_number(2**128-1)
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
certificate_authority-1.1.0 lib/certificate_authority/serial_number.rb
certificate_authority-1.0.0 lib/certificate_authority/serial_number.rb
leap_cli-1.9.2 vendor/certificate_authority/lib/certificate_authority/serial_number.rb
leap_cli-1.9.1 vendor/certificate_authority/lib/certificate_authority/serial_number.rb
leap_cli-1.9 vendor/certificate_authority/lib/certificate_authority/serial_number.rb