Sha256: 56e7e1c975e8db9efd0a044805bf08d27194d7a69c796eb8daf0bdcdf2b964b6

Contents?: true

Size: 676 Bytes

Versions: 2

Compression:

Stored size: 676 Bytes

Contents

module Maxwell
  module Agent
    module Probe
      def self.included(base)
        base.extend(ClassMethods)
        base.instance_eval do
          private_class_method :call_handler, :instance
          attr_accessor :output, :args
        end
      end

      module ClassMethods
        def perform(*args)
          probe = instance(*args)
          probe.output = probe.perform(*args)
          call_handler(probe)
        end

        def instance(*args)
          instance = new
          instance.args = args
          instance
        end

        def call_handler(probe)
          probe.handle if probe.respond_to?(:handle)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
maxwell_agent-0.0.5 lib/maxwell/agent/probe.rb
maxwell_agent-0.0.1 lib/maxwell/agent/probe.rb