Class: Finitio::RelationType

Inherits:
Type
  • Object
show all
Includes:
HeadingBasedType, RelBasedType
Defined in:
lib/finitio/type/relation_type.rb

Overview

The Relation type generator allows capturing sets of information facts, i.e. sets of tuples (of same heading). E.g.

ColoredPoints = {{ point: Point, color: Color }}

This class allows capturing relation types, in a way similar to TupleType:

ColoredPoints = RelationType.new( Heading[...] )

A ruby Set is used as concrete representation, and will contain hashes that are valid representations of the associated tuple type:

R(ColoredPoints) = Set[ R({...}) ] = Set[Hash[...]]

Accordingly, the dress transformation function has the signature below. It expects an Enumerable as input and fails if any duplicate is found (after tuple transformation), or if any tuple fails at being transformed.

dress :: Alpha  -> ColoredPoints   throws TypeError
dress :: Object -> Set[Hash[...]]  throws TypeError

Constant Summary

Constants included from Metadata

Metadata::EMPTY_METADATA

Instance Attribute Summary

Attributes included from HeadingBasedType

#heading

Instance Method Summary collapse

Methods included from RelBasedType

#dress, #generate_data, #include?, #representator, #to_json_schema

Methods included from HeadingBasedType

#==, #[], #hash, #resolve_proxies, #unconstrained

Methods inherited from Type

#==, #anonymous?, #dress, #include?, #name, #name=, #named?, #resolve_proxies, #to_s, #unconstrained

Methods included from Metadata

#metadata, #metadata=, #metadata?

Constructor Details

#initialize(heading, name = nil, metadata = nil) ⇒ RelationType

Returns a new instance of RelationType.



28
29
30
31
32
33
# File 'lib/finitio/type/relation_type.rb', line 28

def initialize(heading, name = nil,  = nil)
  super
  if heading.multi?
    raise ArgumentError, "Multi heading forbidden"
  end
end

Instance Method Details

#default_nameObject



35
36
37
# File 'lib/finitio/type/relation_type.rb', line 35

def default_name
  "{{#{heading.to_name}}}"
end

#suppremum(other) ⇒ Object



39
40
41
# File 'lib/finitio/type/relation_type.rb', line 39

def suppremum(other)
  super(other, RelationType, MultiRelationType)
end