module Axiom::Attribute::LengthComparable
A mixin for attributes that have comparable lengths
Public Class Methods
new(_name, options = EMPTY_HASH)
click to toggle source
Initialize a length comparable attribute
@param [#to_sym] _name
the attribute name
@param [#to_hash] options
the options for the attribute
@option options [Boolean] :required (true)
if true, then the value cannot be nil
@option options [::Integer] :minimum_length
The minimum string length for a valid value
@option options [::Integer] :maximum_length
The maximum string length for a valid value
@return [undefined]
@api private
Calls superclass method
# File lib/axiom/attribute/length_comparable.rb, line 26 def initialize(_name, options = EMPTY_HASH) super min, max = options.values_at(:minimum_length, :maximum_length) if min || max @type = type.new do minimum_length(min) if min maximum_length(max) if max end end end