Class: CertificateAuthority::SerialNumber

Inherits:
Object
  • Object
show all
Includes:
Revocable, Validations
Defined in:
lib/certificate_authority/serial_number.rb

Instance Attribute Summary collapse

Attributes included from Revocable

#revoked_at

Instance Method Summary collapse

Methods included from Revocable

#revoke!, #revoked?

Methods included from Validations

#errors, #valid?

Constructor Details

#initializeSerialNumber

Returns a new instance of SerialNumber.



18
19
20
# File 'lib/certificate_authority/serial_number.rb', line 18

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

Instance Attribute Details

#numberObject

Returns the value of attribute number.



8
9
10
# File 'lib/certificate_authority/serial_number.rb', line 8

def number
  @number
end

Instance Method Details

#validateObject



10
11
12
13
14
15
16
# File 'lib/certificate_authority/serial_number.rb', line 10

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