Class: Axiom::Attribute::String

Inherits:
Object show all
Includes:
Comparable, Function::Predicate::Match::Methods, Function::Predicate::NoMatch::Methods
Defined in:
lib/axiom/attribute/string.rb

Overview

Represents a String value in a relation tuple

Constant Summary

Constants inherited from Axiom::Attribute

FalseClass, TrueClass

Instance Attribute Summary

Attributes inherited from Axiom::Attribute

#name, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Comparable

#asc, #desc

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

Methods included from Function::Predicate::Match::Methods

#match

Methods included from Function::Predicate::NoMatch::Methods

#no_match

Methods included from Function::Predicate::Equality::Methods

#eq

Methods included from Function::Predicate::Exclusion::Methods

#exclude

Methods included from Function::Predicate::Inequality::Methods

#ne

Methods included from Function::Predicate::Inclusion::Methods

#include

Methods included from Axiom::Aggregate::Count::Methods

#count

Methods inherited from Axiom::Attribute

#call, coerce, #include?, infer_type, name_from, #optional?, #rename, #required?

Methods included from Visitable

#accept

Constructor 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 String 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

  • :minimum_length (::Integer)

    The minimum string length for a valid value

  • :maximum_length (::Integer)

    The maximum string length for a valid value



40
41
42
43
44
45
46
47
48
49
# File 'lib/axiom/attribute/string.rb', line 40

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

Class Method Details

.typeClass<Types::String>

The attribute type

Examples:

type = Axiom::Attribute::String.type  # => Axiom::Types::String

Returns:



20
21
22
# File 'lib/axiom/attribute/string.rb', line 20

def self.type
  Types::String
end