Class: ROM::Relation::Composite

Inherits:
Pipeline::Composite show all
Includes:
Materializable
Defined in:
lib/rom/relation/composite.rb

Overview

Left-to-right relation composition used for data-pipelining

Instance Attribute Summary

Attributes inherited from Pipeline::Composite

#left, #right

Instance Method Summary collapse

Methods included from Materializable

#each, #first, #one, #one!, #to_a

Methods inherited from Pipeline::Composite

#>>, #initialize

Methods included from Pipeline::Proxy

#respond_to_missing?

Constructor Details

This class inherits a constructor from ROM::Pipeline::Composite

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ROM::Pipeline::Proxy

Instance Method Details

#call(*args) ⇒ Loaded Also known as: []

Call the pipeline by passing results from left to right

Optional args are passed to the left object

Returns:



20
21
22
23
24
25
26
27
28
29
# File 'lib/rom/relation/composite.rb', line 20

def call(*args)
  relation = left.call(*args)
  response = right.call(relation)

  if response.is_a?(Loaded)
    response
  else
    relation.new(response)
  end
end

#map_to(klass) ⇒ Object



35
36
37
# File 'lib/rom/relation/composite.rb', line 35

def map_to(klass)
  self >> left.map_to(klass).mapper
end