Module: Axiom::Types::LengthComparable
Overview
Add a minimum and maximum length constraint to a type
Class Method Summary collapse
-
.extended(descendant) ⇒ undefined
private
Hook called when module is extended.
Instance Method Summary collapse
-
#finalize ⇒ Axiom::Types::LengthComparable
private
Finalize by setting up a length range constraint.
Class Method Details
.extended(descendant) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Hook called when module is extended
Add #minimum_length and #maximum_length DSL methods to descendant.
18 19 20 21 22 23 24 25 |
# File 'lib/axiom/types/length_comparable.rb', line 18 def self.extended(descendant) super descendant.class_eval do :minimum_length, :maximum_length minimum_length Infinity maximum_length NegativeInfinity end end |
Instance Method Details
#finalize ⇒ Axiom::Types::LengthComparable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finalize by setting up a length range constraint
32 33 34 35 36 |
# File 'lib/axiom/types/length_comparable.rb', line 32 def finalize return self if frozen? has_length_within_range super end |