module Zabby::ZClass::ClassMethods

Attributes

id[R]

The id field name for the model (“actionid”, “hostid”, etc.)

zmethods[R]

List of valid Web Service methods for the current Zabbix Object

Public Instance Methods

class_name() click to toggle source

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
inspect() click to toggle source

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_zmethods(*zmethods) click to toggle source

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
method_missing(zmethod, *args, &block) click to toggle source

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.

Calls superclass method
# 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
primary_key(key) click to toggle source

Set the name of the primary key @param key [String] Primary key name

# File lib/rbZabbix/zclass.rb, line 49
def primary_key(key)
  @id = key.to_sym
end