Module: Axiom::Relation::Proxy

Included in:
Operation::Deletion, Operation::Insertion, Variable
Defined in:
lib/axiom/relation/proxy.rb

Overview

Allow relations to proxy to other relations

Constant Summary collapse

PROXY_METHODS =
%w[header each empty? materialized?].freeze
ENUMERABLE_METHODS =
Enumerable.public_instance_methods.map(&:to_s).freeze
RELATION_METHODS =
Relation.public_instance_methods.map(&:to_s).freeze
REMOVE_METHODS =
PROXY_METHODS | (ENUMERABLE_METHODS - RELATION_METHODS)

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*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.

Forward the message to the relation

Parameters:

  • args (Array)

Returns:

  • (self)

    return self for all command methods

  • (Object)

    return response from all query methods



61
62
63
64
65
66
67
68
# File 'lib/axiom/relation/proxy.rb', line 61

def method_missing(*args, &block)
  response = relation.public_send(*args, &block)
  if response.equal?(relation)
    self
  else
    response
  end
end

Instance Method Details

#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)


45
46
47
# File 'lib/axiom/relation/proxy.rb', line 45

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