Module: Jamf::Abstract
- Included in:
- AdvancedSearch, CollectionResource, GenericReference, JSONObject, Prestage, PrestageSkipSetupItems, Resource, SingletonResource
- Defined in:
- lib/jamf/api/mixins/abstract.rb
Overview
This mixin should be extended in abstract class definitions it will raise an error if those classes are instantiated. It also maintains an array of classes that extend themselves this way and are abstract.
Class Method Summary collapse
- .abstract? ⇒ Boolean
-
.abstract_classes ⇒ Object
Classes will be added to this array as they are exteded by Abstract.
-
.extended(by_class) ⇒ Object
when a class is extended by this module, it gets added to the array of known abstract classes.
Instance Method Summary collapse
-
#new(*args, &block) ⇒ Object
when any extended class or subclass of an extended class is instntiated check that it isn’t in the abstract list.
Class Method Details
.abstract? ⇒ Boolean
44 45 46 |
# File 'lib/jamf/api/mixins/abstract.rb', line 44 def self.abstract? abstract_classes.include? self end |
.abstract_classes ⇒ Object
Classes will be added to this array as they are exteded by Abstract
40 41 42 |
# File 'lib/jamf/api/mixins/abstract.rb', line 40 def self.abstract_classes @abstract_classes ||= [] end |
.extended(by_class) ⇒ Object
when a class is extended by this module, it gets added to the array of known abstract classes
35 36 37 |
# File 'lib/jamf/api/mixins/abstract.rb', line 35 def self.extended(by_class) abstract_classes << by_class end |
Instance Method Details
#new(*args, &block) ⇒ Object
when any extended class or subclass of an extended class is instntiated check that it isn’t in the abstract list.
50 51 52 53 54 |
# File 'lib/jamf/api/mixins/abstract.rb', line 50 def new(*args, &block) raise Jamf::UnsupportedError, "Unsupported: #{self} is an abstract class, cannot be instantiated." if Jamf::Abstract.abstract_classes.include? self super end |