Module: Zabby::ZClass::ClassMethods
- Defined in:
- lib/zabby/zclass.rb
Instance Attribute Summary collapse
-
#zmethods ⇒ Object
readonly
List of valid Web Service methods for the current Zabbix Object.
Instance Method Summary collapse
-
#add_zmethods(*zmethods) ⇒ Object
Add the list of Web Service methods to the current class.
-
#inspect ⇒ String
Human representation of the Zabbix Class.
-
#method_missing(zmethod, *args, &block) ⇒ Object
Simulate methods on the object and call the Zabbix Web Service (“host.get”, “item.create”, etc.).
-
#object_name ⇒ String
Name of the current class without the namespace.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(zmethod, *args, &block) ⇒ Object
Simulate methods on the object and call the Zabbix Web Service (“host.get”, “item.create”, etc.). See www.zabbix.com/documentation/1.8/api for the API documentation.
53 54 55 56 57 58 59 |
# File 'lib/zabby/zclass.rb', line 53 def method_missing(zmethod, *args, &block) if @zmethods.include? zmethod Zabby::Runner.instance.connection.perform_request(object_name, zmethod, args.first) else super end end |
Instance Attribute Details
#zmethods ⇒ Object (readonly)
List of valid Web Service methods for the current Zabbix Object
26 27 28 |
# File 'lib/zabby/zclass.rb', line 26 def zmethods @zmethods end |
Instance Method Details
#add_zmethods(*zmethods) ⇒ Object
Add the list of Web Service methods to the current class.
43 44 45 |
# File 'lib/zabby/zclass.rb', line 43 def add_zmethods(*zmethods) @zmethods = zmethods.map { |f| f.to_sym } end |
#inspect ⇒ String
Human representation of the Zabbix Class
65 66 67 |
# File 'lib/zabby/zclass.rb', line 65 def inspect "<Zabbix Object '#{object_name}', methods: #{@zmethods.join(', ')}>" end |
#object_name ⇒ String
Name of the current class without the namespace
32 33 34 |
# File 'lib/zabby/zclass.rb', line 32 def object_name @object_name ||= self.name.gsub(/^.*::/, '').downcase end |