Module: RASN1::Types::Constrained::ClassMethods

Defined in:
lib/rasn1/types/constrained.rb

Overview

Define class/module methods for RASN1::Types::Constrained module

Instance Method Summary collapse

Instance Method Details

#check_constraint(value) ⇒ Object

Check constraint, if defined

Parameters:

  • value (Object)

    the value of the type to check

Raises:



28
29
30
31
# File 'lib/rasn1/types/constrained.rb', line 28

def check_constraint(value)
  return unless constrained?
  raise ConstraintError.new(self) unless @constraint.call(value)
end

#constrained?Boolean

Check if a constraint is really defined

Returns:



21
22
23
# File 'lib/rasn1/types/constrained.rb', line 21

def constrained?
  @constraint.is_a?(Proc)
end

#constraint=(constraint) ⇒ Proc?

Setter for constraint

Parameters:

  • constraint (Proc, nil)

Returns:

  • (Proc, nil)


15
16
17
# File 'lib/rasn1/types/constrained.rb', line 15

def constraint=(constraint)
  @constraint = constraint
end