Sha256: f23e5580effda96b9922ba238ca058f29f8687ec7ec3147b42a30eb14ffc6522

Contents?: true

Size: 1.12 KB

Versions: 31

Compression:

Stored size: 1.12 KB

Contents

# -*- encoding: utf-8 -*-
module Bluepill
  class ProcessProxy
    attr_reader :attributes, :watches, :name
    def initialize(process_name, attributes, process_block)
      @name = process_name
      @attributes = attributes
      @watches = {}

      if process_block.arity == 0
        instance_eval &process_block
      else
        instance_exec(self, &process_block)
      end
    end

    def method_missing(name, *args)
      if args.size == 1 && name.to_s =~ /^(.*)=$/
        @attributes[$1.to_sym] = args.first
      elsif args.size == 1
        @attributes[name.to_sym] = args.first
      elsif args.size == 0 && name.to_s =~ /^(.*)!$/
        @attributes[$1.to_sym] = true
      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
      Process.new(@name, @watches, @attributes)
    end
  end
end

Version data entries

31 entries across 31 versions & 6 rubygems

Version Path
bluepill-rwgps-0.0.63 lib/bluepill/dsl/process_proxy.rb
bluepill-rwgps-0.0.62 lib/bluepill/dsl/process_proxy.rb
bluepill-rwgps-0.0.61 lib/bluepill/dsl/process_proxy.rb
cloud66-bluepill-0.0.64 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.68 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.67 lib/bluepill/dsl/process_proxy.rb
bluepill-rwgps-0.0.60 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.66 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.65 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.64 lib/bluepill/dsl/process_proxy.rb
cloud66-bluepill-0.0.63 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.63 lib/bluepill/dsl/process_proxy.rb
cloud66-bluepill-0.0.62 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.62 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.61 lib/bluepill/dsl/process_proxy.rb
kostya-bluepill-0.0.60.3 lib/bluepill/dsl/process_proxy.rb
kostya-bluepill-0.0.60.2 lib/bluepill/dsl/process_proxy.rb
kostya-bluepill-0.0.60.1 lib/bluepill/dsl/process_proxy.rb
skalar-bluepill-0.0.60.1 lib/bluepill/dsl/process_proxy.rb
bluepill-0.0.60 lib/bluepill/dsl/process_proxy.rb