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

Class Method Details

.extended(extender) ⇒ Object



59
60
61
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 59

def self.extended(extender)
  Jamf.load_msg "--> #{extender} is extending Jamf::JPAPIResource::ClassMethods"
end

Instance Method Details

#new(**data) ⇒ Object

Disallow direct use of ruby's .new class method for creating instances. Require use of .fetch or .create, or 'all'



72
73
74
75
76
77
78
79
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 72

def new(**data)
  calling_method = caller_locations(1..1).first.label
  unless NEW_CALLERS.include? calling_method
    raise Jamf::UnsupportedError, 'Use .fetch, .create, or .all(instantiate:true) to instantiate Jamf::JPAPIResource objects'
  end

  super(**data)
end

#which_apiObject

Indicate that this class comes from the Jamf Pro API. The same method exists in APIObject to indicate coming from Classic



65
66
67
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 65

def which_api
  :jamf_pro
end