Sha256: 6b9724c87a3e569067b7a7bc7d37df99696669ad65758c3fb7bbcc8312809e3f

Contents?: true

Size: 684 Bytes

Versions: 44

Compression:

Stored size: 684 Bytes

Contents

module Itamae
  class HandlerProxy
    def initialize
      @instances = []
    end

    def register_instance(instance)
      @instances << instance
    end

    def event(*args, &block)
      if block_given?
        _event_with_block(*args, &block)
      else
        _event(*args)
      end
    end

    private

    def _event(*args)
      @instances.each do |i|
        i.event(*args)
      end
    end

    def _event_with_block(event_name, *args, &block)
      event("#{event_name}_started".to_sym, *args)
      block.call
    rescue
      event("#{event_name}_failed".to_sym, *args)
      raise
    else
      event("#{event_name}_completed".to_sym, *args)
    end
  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
itamae-1.14.1 lib/itamae/handler_proxy.rb
itamae-1.14.0 lib/itamae/handler_proxy.rb
itamae-1.13.1 lib/itamae/handler_proxy.rb
itamae-1.13.0 lib/itamae/handler_proxy.rb
itamae-1.12.6 lib/itamae/handler_proxy.rb
itamae-1.12.5 lib/itamae/handler_proxy.rb
itamae-1.12.4 lib/itamae/handler_proxy.rb
itamae-1.12.3 lib/itamae/handler_proxy.rb
itamae-1.12.2 lib/itamae/handler_proxy.rb
itamae-1.12.1 lib/itamae/handler_proxy.rb
itamae-1.12.0 lib/itamae/handler_proxy.rb
itamae-1.11.2 lib/itamae/handler_proxy.rb
itamae-1.11.1 lib/itamae/handler_proxy.rb
itamae-1.11.0 lib/itamae/handler_proxy.rb
itamae-1.10.10 lib/itamae/handler_proxy.rb
itamae-1.10.9 lib/itamae/handler_proxy.rb
itamae-1.10.8 lib/itamae/handler_proxy.rb
itamae-1.10.7 lib/itamae/handler_proxy.rb
itamae-1.10.6 lib/itamae/handler_proxy.rb
itamae-1.10.5 lib/itamae/handler_proxy.rb