Sha256: a9b06ef6f076b9587308eaca571e845c83a9cf4eb6a966d026bcb86d329f9c3e

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

Contents

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

require 'bluepill/process'

module Bluepill
  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
      Bluepill::Process.new(@name, @watches, @attributes)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evented_bluepill-0.0.47 lib/bluepill/dsl/process_proxy.rb