Class: Procmon::ProcessFactory
- Inherits:
-
Object
- Object
- Procmon::ProcessFactory
- Defined in:
- lib/procmon/dsl/process_factory.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#checks(name, options = {}, &block) ⇒ Object
readonly
Returns the value of attribute checks.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #create_process ⇒ Object
-
#initialize(name, attributes, process_block) ⇒ ProcessFactory
constructor
A new instance of ProcessFactory.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(name, attributes, process_block) ⇒ ProcessFactory
Returns a new instance of ProcessFactory.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/procmon/dsl/process_factory.rb', line 4 def initialize(name, attributes, process_block) @checks = {} @name = name @attributes = attributes 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
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/procmon/dsl/process_factory.rb', line 15 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.
3 4 5 |
# File 'lib/procmon/dsl/process_factory.rb', line 3 def attributes @attributes end |
#checks(name, options = {}, &block) ⇒ Object (readonly)
Returns the value of attribute checks.
3 4 5 |
# File 'lib/procmon/dsl/process_factory.rb', line 3 def checks @checks end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/procmon/dsl/process_factory.rb', line 3 def name @name end |