Class: Axiom::Adapter::Arango::Gateway

Inherits:
Relation
  • Object
show all
Defined in:
lib/axiom/adapter/arango/gateway.rb

Overview

A relation backed by an adapter

Constant Summary collapse

DECORATED_CLASS =
superclass

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ self, Object (private)

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.

Proxy the message to the relation

Parameters:

  • method (Symbol)
  • args (Array)

Returns:

  • (self)

    return self for all command methods

  • (Object)

    return response from all query methods



214
215
216
# File 'lib/axiom/adapter/arango/gateway.rb', line 214

def method_missing(method, *args, &block)
  forwardable?(method) ? forward(method, *args, &block) : super
end

Instance Method Details

#difference(other) ⇒ Gateway, Algebra::Difference

Return the difference between relations

Examples:

difference = gateway.difference(other)

Parameters:

  • other (Relation)

    the other relation to find the difference with

Returns:

  • (Gateway)

    return a gateway if the adapters are equal

  • (Algebra::Difference)

    return a normal dfference when the adapters are not equal



141
142
143
# File 'lib/axiom/adapter/arango/gateway.rb', line 141

def difference(other)
  binary_operation(__method__, other, Algebra::Difference)
end

#each {|tuple| ... } ⇒ self

Iterate over each row in the results

Examples:

gateway = Gateway.new(adapter, relation)
gateway.each { |tuple| ... }

Yields:

  • (tuple)

Yield Parameters:

  • tuple (Tuple)

    each tuple in the results

Returns:

  • (self)


30
31
32
33
34
# File 'lib/axiom/adapter/arango/gateway.rb', line 30

def each
  return to_enum unless block_given?
  tuples.each { |tuple| yield tuple }
  self
end

#intersect(other) ⇒ Gateway, Algebra::Intersection

Return the intersection between relations

Examples:

intersect = gateway.intersect(other)

Parameters:

  • other (Relation)

    the other relation to find the intersect with

Returns:

  • (Gateway)

    return a gateway if the adapters are equal

  • (Algebra::Intersection)

    return a normal intersection when the adapters are not equal



123
124
125
# File 'lib/axiom/adapter/arango/gateway.rb', line 123

def intersect(other)
  binary_operation(__method__, other, Algebra::Intersection)
end

#join(other) {|relation| ... } ⇒ Gateway, ...

Return a relation that is the join of two relations

Examples:

natural join

join = relation.join(other)

theta-join using a block

join = relation.join(other) { |r| r.a.gte(r.b) }

Parameters:

  • other (Relation)

    the other relation to join

Yields:

  • (relation)

    optional block to restrict the tuples with

Yield Parameters:

  • relation (Relation)

    the context to evaluate the restriction with

Yield Returns:

  • (Function, #call)

    predicate to restrict the tuples with

Returns:

  • (Gateway)

    return a gateway if the adapters are equal

  • (Algebra::Join)

    return a normal join when the adapters are not equal

  • (Algebra::Restriction)

    return a normal restriction when the adapters are not equal for a theta-join



65
66
67
68
69
70
71
# File 'lib/axiom/adapter/arango/gateway.rb', line 65

def join(other)
  if block_given?
    super
  else
    binary_operation(__method__, other, Algebra::Join)
  end
end

#product(other) ⇒ Gateway, Algebra::Product

Return a relation that is the Cartesian product of two relations

Examples:

product = gateway.product(other)

Parameters:

  • other (Relation)

    the other relation to find the product with

Returns:

  • (Gateway)

    return a gateway if the adapters are equal

  • (Algebra::Product)

    return a normal product when the adapters are not equal



87
88
89
# File 'lib/axiom/adapter/arango/gateway.rb', line 87

def product(other)
  binary_operation(__method__, other, Algebra::Product)
end

#respond_to?(method) ⇒ Boolean

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.

Test if the method is supported on this object

Parameters:

  • method (Symbol)

Returns:

  • (Boolean)


196
197
198
# File 'lib/axiom/adapter/arango/gateway.rb', line 196

def respond_to?(method, *)
  super || forwardable?(method)
end

#summarize(summarize_with = TABLE_DEE) {|function| ... } ⇒ Gateway, Algebra::Summarization

Return a summarized relation

Examples:

with no arguments

summarization = gateway.summarize do |context|
  context.add(:count, context[:id].count)
end

with a relation

summarization = gateway.summarize(relation) do |context|
  context.add(:count, context[:id].count)
end

with a header

summarization = gateway.summarize([ :name ]) do |context|
  context.add(:count, context[:id].count)
end

with another gateway

summarization = gateway.summarize(other_gateway) do |context|
  context.add(:count, context[:id].count)
end

Parameters:

  • summarize_with (Gateway, Relation, Header, #to_ary) (defaults to: TABLE_DEE)

Yields:

  • (function)

    Evaluate a summarization function

Yield Parameters:

  • context (Evaluator::Context)

    the context to evaluate the function within

Returns:

  • (Gateway)

    return a gateway if the adapters are equal, or there is no adapter

  • (Algebra::Summarization)

    return a normal summarization when the adapters are not equal



181
182
183
184
185
186
187
# File 'lib/axiom/adapter/arango/gateway.rb', line 181

def summarize(summarize_with = TABLE_DEE, &block)
  if summarize_merge?(summarize_with)
    summarize_merge(summarize_with, &block)
  else
    summarize_split(summarize_with, &block)
  end
end

#union(other) ⇒ Gateway, Algebra::Union

Return the union between relations

Examples:

union = gateway.union(other)

Parameters:

  • other (Relation)

    the other relation to find the union with

Returns:

  • (Gateway)

    return a gateway if the adapters are equal

  • (Algebra::Union)

    return a normal union when the adapters are not equal



105
106
107
# File 'lib/axiom/adapter/arango/gateway.rb', line 105

def union(other)
  binary_operation(__method__, other, Algebra::Union)
end