Files

Axiom::Types::LengthComparable

Add a minimum and maximum length constraint to a type

Attributes

range[R]

The range of allowed lengths

@return [Range]

@api public

Public Class Methods

extended(descendant) click to toggle source

Hook called when module is extended

Add minimum_length and maximum_length DSL methods to descendant.

@param [Class<Axiom::Types::Type>] descendant

@return [undefined]

@api private

# File lib/axiom/types/length_comparable.rb, line 24
def self.extended(descendant)
  super
  descendant.class_eval do
    accept_options :minimum_length, :maximum_length
    minimum_length Infinity.instance
    maximum_length NegativeInfinity.instance
  end
end

Public Instance Methods

finalize() click to toggle source

Finalize by setting up a length range constraint

@return [Axiom::Types::LengthComparable]

@api private

# File lib/axiom/types/length_comparable.rb, line 38
def finalize
  return self if frozen?
  @range = IceNine.deep_freeze(minimum_length..maximum_length)
  use_length_within_range
  super
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.