Class | Cobbler::Base |
In: |
lib/cobbler/base.rb
|
Parent: | Object |
Base represents a remote Cobbler server.
Child classes can define fields that will be retrieved from Cobbler by using the cobbler_field method. For example:
class System < Base cobbler_lifecycle :find_all => 'get_systems' cobbler_field :name cobbler_collection :owners, :type => 'String', :packing => :hash end
declares a class named System that contains two fields and a class-level method.
The first field, "name", is a simple property. It will be retrieved from the value "name" in the remote definition for a system, identifyed by the +:owner+ argument.
The second field, "owners", is similarly retrieved from a property also named "owners" in the remote definition. However, this property is a collection: in this case, it is an array of definitions itself. The +:type+ argument identifies what the local class type is that will be used to represent each element in the collection.
A cobbler_collection is packed in one of two ways: either as an array of values or as a hash of keys and associated values. These are defined by the +:packing+ argument with the values Array and Hash, respectively.
The cobbler_lifecycle method allows for declaring different methods for retrieving remote instances of the class. These methods are:
find_one - the remote method to find a single instance, find_all - the remote method to find all instances, remove - the remote method to remote an instance
definitions | [RW] |