Sha256: ca2308500d915288a75c0925ae7d4b7d17b1a2193b016744010b57b8fd6330dc

Contents?: true

Size: 749 Bytes

Versions: 7

Compression:

Stored size: 749 Bytes

Contents

module Invokable
  module Compose
    # Return a proc that is the composition of this invokable and the given `invokable`.
    # The returned proc takes a variable number of arguments, calls `invokable` with
    # them then calls this proc with the result.
    #
    # @return [Proc]
    def <<(invokable)
      Proc.new do |*args|
        call(invokable.call(*args))
      end
    end

    # Return a proc that is the composition of this invokable and the given `invokable`.
    # The returned proc takes a variable number of arguments, calls `invokable` with
    # them then calls this proc with the result.
    #
    # @return [Proc]
    def >>(invokable)
      Proc.new do |*args|
        invokable.call(call(*args))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
invokable-0.6.0 lib/invokable/compose.rb
invokable-0.5.2 lib/invokable/compose.rb
invokable-0.5.1 lib/invokable/compose.rb
invokable-0.5.0 lib/invokable/compose.rb
invokable-0.4.2 lib/invokable/compose.rb
invokable-0.4.1 lib/invokable/compose.rb
invokable-0.4.0 lib/invokable/compose.rb