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.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 5 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 17 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 |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 4 def attributes @attributes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 4 def name @name end |
#watches ⇒ Object (readonly)
Returns the value of attribute watches.
4 5 6 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 4 def watches @watches end |
Instance Method Details
#checks(name, options = {}) ⇒ Object
31 32 33 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 31 def checks(name, = {}) @watches[name] = end |
#monitor_children(&child_process_block) ⇒ Object
35 36 37 38 |
# File 'lib/bluepill/dsl/process_proxy.rb', line 35 def monitor_children(&child_process_block) @attributes[:monitor_children] = true @attributes[:child_process_block] = child_process_block end |