Class: Axiom::Attribute::String
- Inherits:
-
Object
- Object
- Axiom::Attribute
- Object
- Axiom::Attribute::String
- Defined in:
- lib/axiom/attribute/string.rb
Overview
Represents a String value in a relation tuple
Constant Summary collapse
- DEFAULT_MIN_LENGTH =
0
- DEFAULT_MAX_LENGTH =
50
Instance Attribute Summary collapse
-
#max_length ⇒ ::Integer
readonly
The maximum string length for a valid value.
-
#min_length ⇒ ::Integer
readonly
The minimum string length for a valid value.
Attributes inherited from Axiom::Attribute
Class Method Summary collapse
-
.primitive ⇒ Class<::String>
The String primitive.
Instance Method Summary collapse
-
#initialize(_name, _options = EMPTY_HASH) ⇒ undefined
constructor
private
Initialize a String Attribute.
-
#valid_value?(value) ⇒ Boolean
Test if the value matches the attribute constraints.
Methods included from Comparable
Methods included from Function::Predicate::GreaterThan::Methods
Methods included from Function::Predicate::GreaterThanOrEqualTo::Methods
Methods included from Function::Predicate::LessThan::Methods
Methods included from Function::Predicate::LessThanOrEqualTo::Methods
Methods included from Axiom::Aggregate::Minimum::Methods
Methods included from Axiom::Aliasable
Methods included from Axiom::Aggregate::Maximum::Methods
Methods included from Axiom::Aggregate::Mean::Methods
Methods included from Axiom::Aggregate::Variance::Methods
Methods included from Axiom::Aggregate::StandardDeviation::Methods
Methods included from Function::Predicate::Match::Methods
Methods included from Function::Predicate::NoMatch::Methods
Methods included from Function::Predicate::Equality::Methods
Methods included from Function::Predicate::Exclusion::Methods
Methods included from Function::Predicate::Inequality::Methods
Methods included from Function::Predicate::Inclusion::Methods
Methods included from Axiom::Aggregate::Count::Methods
Methods inherited from Axiom::Attribute
#call, coerce, infer_type, name_from, #rename, #required?, #type, #valid_primitive?
Methods included from Visitable
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
64 65 66 67 68 |
# File 'lib/axiom/attribute/string.rb', line 64 def initialize(_name, = EMPTY_HASH) super @min_length = @options.fetch(:min_length, DEFAULT_MIN_LENGTH) @max_length = @options.fetch(:max_length, DEFAULT_MAX_LENGTH) end |
Instance Attribute Details
#max_length ⇒ ::Integer (readonly)
The maximum string length for a valid value
34 35 36 |
# File 'lib/axiom/attribute/string.rb', line 34 def max_length @max_length end |
#min_length ⇒ ::Integer (readonly)
The minimum string length for a valid value
24 25 26 |
# File 'lib/axiom/attribute/string.rb', line 24 def min_length @min_length end |
Class Method Details
.primitive ⇒ Class<::String>
The String primitive
44 45 46 |
# File 'lib/axiom/attribute/string.rb', line 44 def self.primitive ::String end |
Instance Method Details
#valid_value?(value) ⇒ Boolean
Test if the value matches the attribute constraints
81 82 83 |
# File 'lib/axiom/attribute/string.rb', line 81 def valid_value?(value) valid_or_optional?(value) { super && valid_length?(value) } end |