# File lib/rbZabbix/zclass.rb, line 49 def primary_key(key) @id = key.to_sym end
module Zabby::ZClass::ClassMethods
Attributes
The id field name for the model (“actionid”, “hostid”, etc.)
List of valid Web Service
methods for the current Zabbix Object
Public Instance Methods
Name of the current class without the namespace @return [String] @example
Zabby::Host.object_name => "Host"
# File lib/rbZabbix/zclass.rb, line 33 def class_name @class_name ||= self.name.split(/::/).last.downcase end
Human representation of the Zabbix Class @return [String] Class representation @example
Host.inspect => "<Zabby::Host methods=(create, delete, exists, get, update)>"
# File lib/rbZabbix/zclass.rb, line 41 def inspect "<#{name} methods=(#{@zmethods.join(', ')})>" end
Private Instance Methods
Add the list of Web Service
methods to the current class. @param [Array] zmethods Method names @example
class Host include ZClass add_zmethods :create, :delete, :exists, :get, :update end
# File lib/rbZabbix/zclass.rb, line 60 def add_zmethods(*zmethods) @zmethods = zmethods.map { |f| f.to_sym } end
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. @param [String] zmethod Name of the Web Service
methods @param [Array] args Method arguments @param [Proc] block Unused @raise [NoMethodError] Raised on invalid method names.
# File lib/rbZabbix/zclass.rb, line 70 def method_missing(zmethod, *args, &block) if @zmethods.include? zmethod Zabby::Runner.instance.connection.perform_request(class_name, zmethod, args.first) else super end end
Set the name of the primary key @param key [String] Primary key name