Sha256: 49890f0d527283a3bf199eb152e4037f01466ab6834ad5b30174cc396fe725d5

Contents?: true

Size: 1017 Bytes

Versions: 11

Compression:

Stored size: 1017 Bytes

Contents

module Pacer
  module Routes
    module RouteOperations
      # This method adds the IsUniquePipe to the pipeline and whenever the
      # pipeline is built, yields the pipe to the block given here.
      #
      # See #unique? below for example usage.
      def is_unique(&block)
        chain_route side_effect: :is_unique, on_build_pipe: block
      end

      # This method builds a pipe and ataches the IsUniquePipe to the end then
      # iterates the pipeline until it finds a unique element or hits the end.
      def unique?
        check = nil
        is_unique { |pipe| check = pipe }.each do
          return false unless check.isUnique
        end
        true
      end
    end
  end


  module SideEffect
    module IsUnique
      attr_accessor :on_build_pipe

      protected

      def attach_pipe(end_pipe)
        checked = Pacer::Pipes::IsUniquePipe.new
        checked.setStarts end_pipe if end_pipe
        on_build_pipe.call checked if on_build_pipe
        checked
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pacer-2.0.24-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.22-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.20-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.19-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.18-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.17-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.16-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.15-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.14-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.13-java lib/pacer/side_effect/is_unique.rb
pacer-2.0.12-java lib/pacer/side_effect/is_unique.rb