Class: Torque::PostgreSQL::PredicateTable

Inherits:
Object
  • Object
show all
Defined in:
lib/torque/postgresql/predicate_table.rb

Overview

Mimics ActiveRecord::TableMetadata so that the parts of a value that holds other values, like the columns of a composite type or the properties of a document, can be treated as the columns of the value they belong to. That is what allows each of them to be handed back to the predicate builder

The handler is the one that knows how to resolve a name, and the node is the one that knows how to reach it

Instance Method Summary collapse

Constructor Details

#initialize(handler, source, node) ⇒ PredicateTable

Returns a new instance of PredicateTable.



13
14
15
16
17
# File 'lib/torque/postgresql/predicate_table.rb', line 13

def initialize(handler, source, node)
  @handler = handler
  @source = source
  @node = node
end

Instance Method Details

#[](name) ⇒ Object



23
24
25
# File 'lib/torque/postgresql/predicate_table.rb', line 23

def [](name)
  @node.new(@source, name, *@handler.type_of(name))
end

#aggregated_with?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/torque/postgresql/predicate_table.rb', line 48

def aggregated_with?(*)
  false
end

#arel_tableObject



19
20
21
# File 'lib/torque/postgresql/predicate_table.rb', line 19

def arel_table
  self
end

#associated_withObject Also known as: associated_with?

Rails 8.1 renamed this, so both names answer for the supported versions



42
43
44
# File 'lib/torque/postgresql/predicate_table.rb', line 42

def associated_with(*)
  false
end

#has_column?Boolean

Anything that gets here is meant to be resolved as a part of the value, which is what type_of is there to accept or reject

Returns:

  • (Boolean)


33
34
35
# File 'lib/torque/postgresql/predicate_table.rb', line 33

def has_column?(*)
  true
end

#polymorphic_association?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/torque/postgresql/predicate_table.rb', line 52

def polymorphic_association?
  false
end

#primary_keyObject



37
38
39
# File 'lib/torque/postgresql/predicate_table.rb', line 37

def primary_key
  nil
end

#through_association?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/torque/postgresql/predicate_table.rb', line 56

def through_association?
  false
end

#type(name) ⇒ Object



27
28
29
# File 'lib/torque/postgresql/predicate_table.rb', line 27

def type(name)
  @handler.type_of(name).first
end