Sha256: 3d8c5cd17698fb26a25475df8ddc44490be9220aa659526a5637a32920d16817

Contents?: true

Size: 370 Bytes

Versions: 8

Compression:

Stored size: 370 Bytes

Contents

module Pallets
  module Middleware
    # Array-like class that acts like a stack and additionally provides the
    # means to wrap an operation with callable objects
    class Stack < Array
      def invoke(*args, &block)
        reverse.inject(block) do |memo, middleware|
          lambda { middleware.call(*args, &memo) }
        end.call
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pallets-0.11.0 lib/pallets/middleware/stack.rb
pallets-0.10.0 lib/pallets/middleware/stack.rb
pallets-0.9.0 lib/pallets/middleware/stack.rb
pallets-0.8.0 lib/pallets/middleware/stack.rb
pallets-0.7.0 lib/pallets/middleware/stack.rb
pallets-0.6.0 lib/pallets/middleware/stack.rb
pallets-0.5.1 lib/pallets/middleware/stack.rb
pallets-0.5.0 lib/pallets/middleware/stack.rb