Sha256: 8dfab9a23c0b4aa879e135779285b63955b191267d82262a3bc0a3e0a0d7ed56

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'evented_bluepill/process'

module EventedBluepill
  class ProcessProxy
    attr_reader :attributes, :watches, :name
    def initialize(process_name, attributes, process_block)
      @name = process_name
      @attributes = attributes
      @watches = {}

      process_block.call(self)
    end

    def method_missing(name, *args)
      if args.size == 1 && name.to_s =~ /^(.*)=$/
        @attributes[$1.to_sym] = args.first
      elsif args.empty? && @attributes.key?(name.to_sym)
        @attributes[name.to_sym]
      else
        super
      end
    end

    def checks(name, options = {})
      @watches[name] = options
    end

    def monitor_children(&child_process_block)
      @attributes[:monitor_children] = true
      @attributes[:child_process_block] = child_process_block
    end

    def to_process
      EventedBluepill::Process.new(@name, @watches, @attributes)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evented_bluepill-0.0.52 lib/evented_bluepill/dsl/process_proxy.rb
evented_bluepill-0.0.51 lib/evented_bluepill/dsl/process_proxy.rb
evented_bluepill-0.0.50 lib/evented_bluepill/dsl/process_proxy.rb