class Chook::Subject
This is the MetaClass for all Subject
objects, both handled and test. It holds constants, methods, and attributes that are common to all subjects in Chook
A 'subject' within Chook
is the ruby-abstraction of a the 'event_object' part of the JSON payload of an event.
All events contain a subject attribute, which represent the thing upon which the event acted, e.g. a computer, mobile divice, or the JSS itself. Those attributes are objects which are subclasses of Chook::Subject
, q.v.
Constants
- COMPUTER
The name of the Computer subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- DEP_DEVICE
The name of the DeviceAddedtoDEP subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- JAMF_SOFTWARE_SERVER
The name of the JSS subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- MOBILE_DEVICE
The name of the MobileDevice subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- NAME_CONSTANT
the various subclasses of
Subject
will have a constant SUBJECT_NAME that contains a string - the name of the subject as known to the JSS- PATCH_SW_UPDATE
The name of the PatchSoftwareTitleUpdated subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- POLICY_FINISHED
The name of the ComputerPolicyFinished subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- PUSH
The name of the Push subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- REST_API_OPERATION
The name of the RestAPIOperation subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- SCEP_CHALLENGE
The name of the SCEPChallenge subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
- SMART_GROUP
The name of the SmartGroup subject (a.k.a. 'event_object') as known to the JSS. Also the class name of such subjects in
Chook::HandledSubjects
andChook::TestSubjects
Public Class Methods
Define a 'classes' class method (actually a class-instance attribute) that defines all of the possible Subject
subclasses so they can be dynamically created.
The definitions will be added as the subject-files are loaded.
This method returns a Hash with one item per subject-type.
The key is the subject name [String] as known to the JSS and is defined in a Constant in Chook::Subject
, e.g. Chook::Subject::COMPUTER
= 'Computer'. That name is also used for the class names of the subject classes in the HandledSubjects
and TestSubjects
modules.
The values are also hashes, with one item per attribute for that subject-type. The keys are the attribute names as Symbols, and the values are hashes defining the attribute. Attributes may have these keys:
:converter => a Proc or a method-name (as a Symbol) to convert the raw value to its interally stored version. E.g. Time objects in JSON are left as Strings by the JSON.parse method. A converter can be used to make it a Time object. :validation => Class or Proc. When creating a TestSubject, this attribute is settable, and new values are validated. If a Class, then the new value must be an instance of the class. If a Proc, the value is passed to the proc, which must return True. :randomizer => Symbol. When creating a TestSubject, this is the class-method to call on Chook::TestSubject to generate a valid random value for this attribute. :sampler => Symbol: When creating a TestSubject, this is the Chook::TestSubject class method which will pull a random value from a real JSS. :api_object_attribute => Symbol or Array of Symbols or a Proc: When creating a TestSubject, this represents the location of values in an API object Symbol: A method name to call on an API object Array: Array[0] is a method name to call on an API object subsequent items are Hash keys to be called on Array[0]'s output Proc: Pass an API object to the PROC to get a value
# File lib/chook/subject.rb, line 134 def self.classes @classes ||= {} end