Class: Coreimpact::Module
- Inherits:
-
Object
- Object
- Coreimpact::Module
- Defined in:
- lib/coreimpact/module.rb
Instance Method Summary collapse
-
#initialize(xml_module) ⇒ Module
constructor
A new instance of Module.
-
#method_missing(method, *args) ⇒ Object
Example XML: <property type=“container” key=“Modules”> <property type=“container” key=“<Title>”> <property type=“bool” key=“agent_deployed”>false</property> <property type=“string” key=“description”> Some description.
- #respond_to?(method, include_private = false) ⇒ Boolean
- #supported_tags ⇒ Object
Constructor Details
permalink #initialize(xml_module) ⇒ Module
Returns a new instance of Module.
3 4 5 |
# File 'lib/coreimpact/module.rb', line 3 def initialize(xml_module) @xml = xml_module end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
permalink #method_missing(method, *args) ⇒ Object
Example XML: <property type=“container” key=“Modules”>
<property type="container" key="<Title>">
<property type="bool" key="agent_deployed">false</property>
<property type="string" key="description">
Some description.
</property>
<property type="string" key="port">443</property>
<property type="bool" key="tried_to_install_agent">false</property>
</property>
</property>
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/coreimpact/module.rb', line 28 def method_missing(method, *args) # We could remove this check and return nil for any non-recognized tag. # The problem would be that it would make tricky to debug problems with # typos. For instance: <>.potr would return nil instead of raising an # exception unless .include?(method) super return end @xml.at_xpath("./property[@type='container']/property[@key='#{method}']").text || 'n/a' end |
Instance Method Details
permalink #respond_to?(method, include_private = false) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/coreimpact/module.rb', line 11 def respond_to?(method, include_private = false) return true if .include?(method.to_sym) super end |
permalink #supported_tags ⇒ Object
[View source]
7 8 9 |
# File 'lib/coreimpact/module.rb', line 7 def [:agent_deployed, :description, :port, :tried_to_install_agent] end |