Sha256: 43e0ef956fae9a1b62aad1146916dcf76b01bce48179e35ef4b042faa6126c7a

Contents?: true

Size: 435 Bytes

Versions: 2

Compression:

Stored size: 435 Bytes

Contents

require 'wisper'

module Transflow
  class Publisher
    include Wisper::Publisher

    attr_reader :name

    attr_reader :op

    def initialize(name, op)
      @name = name
      @op = op
    end

    def call(*args)
      result = op.call(*args)
      broadcast(:"#{name}_success", result)
      result
    rescue => err
      broadcast(:"#{name}_failure", *args, err)
      raise err
    end
    alias_method :[], :call
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transflow-0.1.0 lib/transflow/publisher.rb
transflow-0.0.2 lib/transflow/publisher.rb