Class: Axiom::Attribute::Relation

Inherits:
Object show all
Defined in:
lib/axiom/attribute/relation.rb

Overview

Represents a Relation value in a relation tuple

Constant Summary

Constants inherited from Axiom::Attribute

FalseClass, TrueClass

Instance Attribute Summary collapse

Attributes inherited from Axiom::Attribute

#name, #type

Class Method Summary collapse

Instance Method Summary collapse

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 Axiom::Aliasable

#inheritable_alias

Methods included from Visitable

#accept

Constructor Details

#initialize(_name, options) ⇒ 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 Relation Attribute

Parameters:

  • _name (#to_sym)

    the attribute name

  • options (Hash)

    the options for the attribute

Options Hash (options):

  • :required (Boolean) — default: true

    if true, then the value cannot be nil

  • :header (Header)

    the header for the relation



31
32
33
34
# File 'lib/axiom/attribute/relation.rb', line 31

def initialize(_name, options)
  super
  @header = Axiom::Relation::Header.coerce(options.fetch(:header))
end

Instance Attribute Details

#headerHeader (readonly)

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.

The tuple header

Returns:

  • (Header)


15
16
17
# File 'lib/axiom/attribute/relation.rb', line 15

def header
  @header
end

Class Method Details

.typeClass<Types::Relation>

The attribute type

Examples:

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

Returns:



44
45
46
# File 'lib/axiom/attribute/relation.rb', line 44

def self.type
  Types::Relation
end

Instance Method Details

#new_relation(tuples) ⇒ Relation

Initialize a new relation with the tuples provided

Examples:

relation = attribute.new_relation(tuples)

Parameters:

  • tuples (Enumerable)

Returns:



58
59
60
# File 'lib/axiom/attribute/relation.rb', line 58

def new_relation(tuples)
  type.primitive.new(@header, tuples)
end