Module: RASN1::Types::Constrained::ClassMethods
- Included in:
- RASN1::Types::Constrained
- Defined in:
- lib/rasn1/types/constrained.rb
Overview
Define class/module methods for RASN1::Types::Constrained module
Instance Attribute Summary collapse
-
#constraint ⇒ Proc
Proc to check constraints.
Instance Method Summary collapse
-
#check_constraint(value) ⇒ Object
Check constraint, if defined.
-
#constrained? ⇒ Boolean
Check if a constraint is really defined.
Instance Attribute Details
#constraint ⇒ Proc
Returns proc to check constraints.
13 14 15 |
# File 'lib/rasn1/types/constrained.rb', line 13 def constraint @constraint end |
Instance Method Details
#check_constraint(value) ⇒ Object
Check constraint, if defined
24 25 26 27 |
# File 'lib/rasn1/types/constrained.rb', line 24 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
17 18 19 |
# File 'lib/rasn1/types/constrained.rb', line 17 def constrained? @constraint.is_a?(Proc) end |