Class: EventedBluepill::ProcessProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/evented_bluepill/dsl/process_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(process_name, attributes, process_block) ⇒ ProcessProxy

Returns a new instance of ProcessProxy.



8
9
10
11
12
13
14
# File 'lib/evented_bluepill/dsl/process_proxy.rb', line 8

def initialize(process_name, attributes, process_block)
  @name = process_name
  @attributes = attributes
  @watches = {}

  process_block.call(self)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/evented_bluepill/dsl/process_proxy.rb', line 16

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/evented_bluepill/dsl/process_proxy.rb', line 7

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/evented_bluepill/dsl/process_proxy.rb', line 7

def name
  @name
end

#watchesObject (readonly)

Returns the value of attribute watches.



7
8
9
# File 'lib/evented_bluepill/dsl/process_proxy.rb', line 7

def watches
  @watches
end

Instance Method Details

#checks(name, options = {}) ⇒ Object



26
27
28
# File 'lib/evented_bluepill/dsl/process_proxy.rb', line 26

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

#monitor_children(&child_process_block) ⇒ Object



30
31
32
33
# File 'lib/evented_bluepill/dsl/process_proxy.rb', line 30

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

#to_processObject



35
36
37
# File 'lib/evented_bluepill/dsl/process_proxy.rb', line 35

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