Class: PgGraph::Data::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_graph/data/data.rb

Direct Known Subclasses

DatabaseObject, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, dimension: nil) ⇒ Node

Returns a new instance of Node.



19
20
21
22
23
24
# File 'lib/pg_graph/data/data.rb', line 19

def initialize(type, dimension: nil)
  constrain type, PgGraph::Type::Node
  Dimension.validate(dimension) if dimension
  @type = type
  @dimension = dimension
end

Instance Attribute Details

#dimensionObject (readonly)

Dimension of the node



17
18
19
# File 'lib/pg_graph/data/data.rb', line 17

def dimension
  @dimension
end

#typeObject (readonly)

Type of the node (a PgGraph::Type::Node object)



11
12
13
# File 'lib/pg_graph/data/data.rb', line 11

def type
  @type
end

Instance Method Details

#dataObject

Node converted to plain ruby objects structured as given by #dimension. This is the same as #value except for M:M associations



28
# File 'lib/pg_graph/data/data.rb', line 28

def data() @impl end

#inspect(payload = inspect_inner) ⇒ Object



40
41
42
# File 'lib/pg_graph/data/data.rb', line 40

def inspect(payload = inspect_inner)
  "#<#{self.class}:#{uid}#{payload ? " #{payload}" : ""}>"
end

#objectObject

Usually the node itself but associations redefines this to be the associated object. It is used in client code to reference the value object of an associated field, ie: node.object.value() will give you the value of a field even if the field is an association



38
# File 'lib/pg_graph/data/data.rb', line 38

def object() self end

#to_hObject

Raises:

  • (NotThis)


44
# File 'lib/pg_graph/data/data.rb', line 44

def to_h() raise NotThis end

#to_yamlObject

Raises:

  • (NotThis)


45
# File 'lib/pg_graph/data/data.rb', line 45

def to_yaml() raise NotThis end

#valueObject

Node converted to plain ruby objects structured as given by the dimension kind but with flattened M:M associations so duplicates can happen



32
# File 'lib/pg_graph/data/data.rb', line 32

def value() data end

#value_typeObject

Type of the value of a node



14
# File 'lib/pg_graph/data/data.rb', line 14

def value_type() type end