Class: Bluepill::ProcessProxy
- Inherits:
-
Object
- Object
- Bluepill::ProcessProxy
- Defined in:
- lib/bluepill/dsl/process_proxy.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#watches ⇒ Object
readonly
Returns the value of attribute watches.
Instance Method Summary collapse
- #checks(name, options = {}) ⇒ Object
-
#initialize(process_name, attributes, process_block) ⇒ ProcessProxy
constructor
A new instance of ProcessProxy.
- #method_missing(name, *args) ⇒ Object
- #monitor_children(&child_process_block) ⇒ Object
- #to_process ⇒ Object
Constructor Details
#initialize(process_name, attributes, process_block) ⇒ ProcessProxy
Returns a new instance of ProcessProxy.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 4 def initialize(process_name, attributes, process_block) @name = process_name @attributes = attributes @watches = {} if process_block.arity.zero? instance_eval(&process_block) else instance_exec(self, &process_block) end 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 25 26 27 28 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 16 def method_missing(name, *args) if args.size == 1 && name.to_s =~ /^(.*)=$/ @attributes[Regexp.last_match[1].to_sym] = args.first elsif args.size == 1 @attributes[name.to_sym] = args.first elsif args.size == 0 && name.to_s =~ /^(.*)!$/ @attributes[Regexp.last_match[1].to_sym] = true elsif args.empty? && @attributes.key?(name.to_sym) @attributes[name.to_sym] else super end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 3 def attributes @attributes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 3 def name @name end |
#watches ⇒ Object (readonly)
Returns the value of attribute watches.
3 4 5 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 3 def watches @watches end |
Instance Method Details
#checks(name, options = {}) ⇒ Object
30 31 32 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 30 def checks(name, = {}) @watches[name] = end |
#monitor_children(&child_process_block) ⇒ Object
34 35 36 37 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 34 def monitor_children(&child_process_block) @attributes[:monitor_children] = true @attributes[:child_process_block] = child_process_block end |