Sha256: fab669efe04d8548f720eae34ff19ed12bea7c6d438575aa2da807c261f1d94f

Contents?: true

Size: 927 Bytes

Versions: 9

Compression:

Stored size: 927 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 response.is_a?(Loaded)
          response
        else
          relation.new(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

9 entries across 9 versions & 1 rubygems

Version Path
rom-core-4.1.2 lib/rom/relation/composite.rb
rom-core-4.1.1 lib/rom/relation/composite.rb
rom-core-4.1.0 lib/rom/relation/composite.rb
rom-core-4.0.2 lib/rom/relation/composite.rb
rom-core-4.0.1 lib/rom/relation/composite.rb
rom-core-4.0.0 lib/rom/relation/composite.rb
rom-core-4.0.0.rc2 lib/rom/relation/composite.rb
rom-core-4.0.0.rc1 lib/rom/relation/composite.rb
rom-core-4.0.0.beta3 lib/rom/relation/composite.rb