module Jamf::BaseClass

This mixin should be extended in base class definitions it will raise an error if those classes are instantiated or allocated It also maintains an array of classes that extend themselves this way

Constants

ALLOCATION_ACTION
DEFAULT_ACTION
INSTANTIATION_ACTION

Public Class Methods

base_classes() click to toggle source

Classes will be added to this array as they are exteded by BaseClass

   # File lib/jamf/base_class.rb
44 def self.base_classes
45   @base_classes ||= []
46 end
extended(by_class) click to toggle source

when a class is extended by this module, it gets added to the array of known base classes

   # File lib/jamf/base_class.rb
39 def self.extended(by_class)
40   base_classes << by_class
41 end
stop_if_base_class(klass, action = DEFAULT_ACTION) click to toggle source

raise an exception if a given class is a base class

   # File lib/jamf/base_class.rb
49 def self.stop_if_base_class(klass, action = DEFAULT_ACTION)
50   raise Jamf::UnsupportedError, "#{klass} is a base class and cannot #{action}." if base_classes.include? klass
51 end

Public Instance Methods

base_class?() click to toggle source
   # File lib/jamf/base_class.rb
53 def base_class?
54   Jamf::BaseClass.base_classes.include? self
55 end
new(*args, **kwargs, &block) click to toggle source

Can’t instantiate if base_class

Calls superclass method
   # File lib/jamf/base_class.rb
64 def new(*args, **kwargs, &block)
65   stop_if_base_class INSTANTIATION_ACTION
66   super(*args, **kwargs, &block)
67 end
stop_if_base_class(action = DEFAULT_ACTION) click to toggle source

raise an exception if this class is a base class

   # File lib/jamf/base_class.rb
70 def stop_if_base_class(action = DEFAULT_ACTION)
71   Jamf::BaseClass.stop_if_base_class self, action
72 end