Sha256: 77c5e841294afe466fc1eec531ddcf00fe44bb064144ce31c2564e1cf2dc4f0d

Contents?: true

Size: 949 Bytes

Versions: 6

Compression:

Stored size: 949 Bytes

Contents

require 'rom/relation/loaded'
require 'rom/relation/materializable'
require 'rom/pipeline'

module ROM
  class Relation
    # Left-to-right relation composition used for data-pipelining
    #
    # @api public
    class Composite < Pipeline::Composite
      include Materializable

      # Call the pipeline by passing results from left to right
      #
      # Optional args are passed to the left object
      #
      # @return [Loaded]
      #
      # @api public
      def call(*args)
        relation = left.call(*args)
        response = right.call(relation)

        if relation.is_a?(Loaded)
          relation.new(response)
        else
          Loaded.new(relation, response)
        end
      end
      alias_method :[], :call

      private

      # @api private
      #
      # @see Pipeline::Proxy#decorate?
      #
      # @api private
      def decorate?(response)
        super || response.is_a?(Graph)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rom-0.9.0.rc1 lib/rom/relation/composite.rb
rom-0.9.0.beta1 lib/rom/relation/composite.rb
rom-0.8.1 lib/rom/relation/composite.rb
rom-0.8.0 lib/rom/relation/composite.rb
rom-0.7.1 lib/rom/relation/composite.rb
rom-0.7.0 lib/rom/relation/composite.rb