Class: Jamf::SingletonResource Abstract

Inherits:
Resource show all
Extended by:
Abstract
Defined in:
lib/jamf/api/abstract_classes/singleton_resource.rb

Overview

This class is abstract.

A Singleton Resource in the API.

See Resource for details and required constants

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Jamf::JSONObject

Class Method Details

.fetch(reload = false, cnx: Jamf.cnx) ⇒ Jamf::SingletonResource

Return a SingletonResource from the API, from the cache if already cached or retrieving from the API and caching it if neededl



58
59
60
61
62
63
64
65
# File 'lib/jamf/api/abstract_classes/singleton_resource.rb', line 58

def self.fetch(reload = false, cnx: Jamf.cnx)
  cnx.singleton_cache[self] = nil if reload
  cached = cnx.singleton_cache[self]
  return cached if cached

  data = cnx.get rsrc_path
  cnx.singleton_cache[self] = new data, cnx: cnx
end

.flushcache(cnx: Jamf.cnx) ⇒ Object

fetch



67
68
69
70
# File 'lib/jamf/api/abstract_classes/singleton_resource.rb', line 67

def self.flushcache(cnx: Jamf.cnx)
  validate_not_abstract
  cnx.singleton_cache[self] = nil
end

.new(*args, &block) ⇒ Object Originally defined in module Abstract

when any extended class or subclass of an extended class is instntiated check that it isn’t in the abstract list.

Instance Method Details

#exist?Boolean

singltons always exist



81
82
83
# File 'lib/jamf/api/abstract_classes/singleton_resource.rb', line 81

def exist?
  true
end

#rsrc_pathObject

only have one path



76
77
78
# File 'lib/jamf/api/abstract_classes/singleton_resource.rb', line 76

def rsrc_path
  self.class.rsrc_path
end