Method: Jamf::OAPIObject.parse_oapi_properties
- Defined in:
- lib/jamf/api/jamf_pro/base_classes/oapi_object.rb
.parse_oapi_properties ⇒ Object
create getters and setters for subclasses of APIObject based on their OAPI_PROPERTIES Hash.
This method can’t be private, cuz we want to call it from a Zeitwerk callback when subclasses are loaded.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/jamf/api/jamf_pro/base_classes/oapi_object.rb', line 74 def self.parse_oapi_properties # only do this once return if @oapi_properties_parsed # only if this constant is defined return unless defined? self::OAPI_PROPERTIES # TODO: is the concept of 'primary' needed anymore? got_primary = false self::OAPI_PROPERTIES.each do |attr_name, attr_def| Jamf.load_msg "Creating getters and setters for attribute '#{attr_name}' of #{self}" # see above comment # don't make one for :id, that one's hard-coded into CollectionResource # create_list_methods(attr_name, attr_def) if need_list_methods && attr_def[:identifier] && attr_name != :id # there can be only one (primary ident) if attr_def[:identifier] == :primary raise Jamf::UnsupportedError, 'Two identifiers marked as :primary' if got_primary got_primary = true end # create getter unless the attr is write only create_getters attr_name, attr_def unless attr_def[:writeonly] # Don't crete setters for readonly attrs, or immutable objects next if attr_def[:readonly] || !mutable? create_setters attr_name, attr_def end # do |attr_name, attr_def| @oapi_properties_parsed = true end |