Module: Jamf::JPAPIResource::ClassMethods
- Included in:
- CollectionResource::ClassMethods
- Defined in:
- lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb
Overview
Class Methods
Class Method Summary collapse
Instance Method Summary collapse
-
#new(**data) ⇒ Object
Disallow direct use of ruby’s .new class method for creating instances.
-
#which_api ⇒ Object
Indicate that this class comes from the Jamf Pro API.
Class Method Details
Instance Method Details
#new(**data) ⇒ Object
Disallow direct use of ruby’s .new class method for creating instances. Require use of a method in NEW_CALLERS, or the data must include :instantiate_me
WARNING: do not abuse :instantiate_me, it exists so we don’t constantly have to update NEW_CALLERS
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 84 def new(**data) calling_method = caller_locations(1..1).first.label unless NEW_CALLERS.include? calling_method || data[:instantiate_me] raise Jamf::UnsupportedError, 'Use .fetch, .create, or .all(instantiate:true) to instantiate Jamf::JPAPIResource objects' end data.delete :instantiate_me super(**data) end |
#which_api ⇒ Object
Indicate that this class comes from the Jamf Pro API. The same method exists in APIObject to indicate coming from Classic
73 74 75 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 73 def which_api :jamf_pro end |