Sha256: a423bd8fe2c4e74ec26ef1635a6c0bf990b453771383a7710f8447ec4d5bdc06

Contents?: true

Size: 392 Bytes

Versions: 5

Compression:

Stored size: 392 Bytes

Contents

class Cps

  # Syntactic sugar for and_then chains.
  def self.seq(&block)
    s = Seq.new
    block.call(s.method(:chain))
    s.m
  end

  class Seq
    def m
      @m ||= Cps.identity # we need an initial Cps to chain onto
    end

    def chain(proc=nil, &block)
      @m = m.and_then(&(proc || block))
    end
  end
end

class Method
  alias_method :en, :call # to be called `th.en`
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mercury_amqp-0.1.5 lib/mercury/cps/seq.rb
mercury_amqp-0.1.4 lib/mercury/cps/seq.rb
mercury_amqp-0.1.3 lib/mercury/cps/seq.rb
mercury_amqp-0.1.2 lib/mercury/cps/seq.rb
mercury_amqp-0.1.0 lib/mercury/cps/seq.rb