Module: Axiom::Attribute::ValueComparable

Overview

A mixin for attributes that have comparable values

Instance Method Summary collapse

Methods included from Comparable

#asc, #desc, #range

Methods included from Function::Predicate::GreaterThan::Methods

#gt

Methods included from Function::Predicate::GreaterThanOrEqualTo::Methods

#gte

Methods included from Function::Predicate::LessThan::Methods

#lt

Methods included from Function::Predicate::LessThanOrEqualTo::Methods

#lte

Methods included from Axiom::Aggregate::Minimum::Methods

#minimum

Methods included from Axiom::Aliasable

#inheritable_alias

Methods included from Axiom::Aggregate::Maximum::Methods

#maximum

Methods included from Axiom::Aggregate::Mean::Methods

#mean

Methods included from Axiom::Aggregate::Variance::Methods

#variance

Methods included from Axiom::Aggregate::StandardDeviation::Methods

#standard_deviation

Instance Method Details

#initialize(_name, options = EMPTY_HASH) ⇒ 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.

Initialize a value comparable attribute

Parameters:

  • _name (#to_sym)

    the attribute name

  • options (#to_hash) (defaults to: EMPTY_HASH)

    the options for the attribute

Options Hash (options):

  • :required (Boolean) — default: true

    if true, then the value cannot be nil

  • :size (Range<::Numeric>)

    The numeric range for a valid value

Returns:

  • (undefined)


29
30
31
32
33
34
35
36
37
38
# File 'lib/axiom/attribute/value_comparable.rb', line 29

def initialize(_name, options = EMPTY_HASH)
  super
  size = options[:size]
  if size
    @type = type.new do
      minimum(size.first)
      maximum(size.last)
    end
  end
end