Sha256: 2714b117e4778c055a162f5cb46616c44ea1077c0062bfbfe3c3319ffd6ef2d4

Contents?: true

Size: 558 Bytes

Versions: 8

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Common
    module Plugins
      module HasCallbacks
        class Middleware < Core::MethodChainMiddleware
          def next(...)
            entity.callbacks.for([:before, method]).each { |callback| callback.call_in_context(entity) }

            original_value = chain.next(...)

            entity.callbacks.for([:after, method]).reverse_each { |callback| callback.call_in_context(entity, original_value) }

            original_value
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.6.0 lib/convenient_service/common/plugins/has_callbacks/middleware.rb
convenient_service-0.5.0 lib/convenient_service/common/plugins/has_callbacks/middleware.rb
convenient_service-0.4.0 lib/convenient_service/common/plugins/has_callbacks/middleware.rb
convenient_service-0.3.1 lib/convenient_service/common/plugins/has_callbacks/middleware.rb
convenient_service-0.3.0 lib/convenient_service/common/plugins/has_callbacks/middleware.rb
convenient_service-0.2.1 lib/convenient_service/common/plugins/has_callbacks/middleware.rb
convenient_service-0.2.0 lib/convenient_service/common/plugins/has_callbacks/middleware.rb
convenient_service-0.1.0 lib/convenient_service/common/plugins/has_callbacks/middleware.rb