Sha256: ddba62292f840e5d7f42b34bd04db65592764370b13b33c9a033821e5b84e213

Contents?: true

Size: 597 Bytes

Versions: 3

Compression:

Stored size: 597 Bytes

Contents

module FlowObject
  class Callbacks
    SUPPORTED = %i[
      after_input_initialize
      after_flow_initialize
      after_input_check
      after_flow_check
      after_output_initialize
    ].freeze

    NOOP = proc {}.freeze

    def initialize
      @callbacks = Hash.new { |hash, key| hash[key] = NOOP }
    end

    def method_missing(name, *_attrs, &block)
      if SUPPORTED.include?(name)
        block_given? ? @callbacks[name] = block : @callbacks[name]
      else
        super
      end
    end

    def respond_to_missing?(name, *)
      SUPPORTED.include?(name)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flow_object-0.2.3 lib/flow_object/callbacks.rb
flow_object-0.2.2 lib/flow_object/callbacks.rb
flow_object-0.2.1 lib/flow_object/callbacks.rb