Class: Zabby::ZObject
- Inherits:
-
Object
- Object
- Zabby::ZObject
- Defined in:
- lib/zabby/zobject.rb
Overview
Definition of the Zabbix Objects as provided by the Zabbix API
Instance Attribute Summary collapse
-
#zmethods ⇒ Object
readonly
Returns the value of attribute zmethods.
-
#zname ⇒ Object
readonly
Returns the value of attribute zname.
Instance Method Summary collapse
-
#initialize(zname, zmethods) ⇒ ZObject
constructor
Define the Zabbix object name and associated methods.
-
#method_missing(zmethod, *args, &block) ⇒ Object
Simulate methods on the object.
Constructor Details
#initialize(zname, zmethods) ⇒ ZObject
Define the Zabbix object name and associated methods
15 16 17 18 |
# File 'lib/zabby/zobject.rb', line 15 def initialize(zname, zmethods) @zname = zname @zmethods = zmethods.map { |f| f.to_sym } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(zmethod, *args, &block) ⇒ Object
Simulate methods on the object. For example: “host.get”, “item.create”.. The instance variable @zmethods is the list of valid methods.
23 24 25 26 27 28 29 |
# File 'lib/zabby/zobject.rb', line 23 def method_missing(zmethod, *args, &block) if @zmethods.include? zmethod Zabby::Runner.instance.connection.perform_request(@zname, zmethod, args.first) else super end end |
Instance Attribute Details
#zmethods ⇒ Object (readonly)
Returns the value of attribute zmethods.
9 10 11 |
# File 'lib/zabby/zobject.rb', line 9 def zmethods @zmethods end |
#zname ⇒ Object (readonly)
Returns the value of attribute zname.
9 10 11 |
# File 'lib/zabby/zobject.rb', line 9 def zname @zname end |