Module: Jamf::Extendable
- Defined in:
- lib/jamf/api/mixins/extendable.rb
Instance Method Summary collapse
- #ext_attr_names ⇒ Object
-
#ext_attrs ⇒ Object
The Array of extensionAttributes converted to a Hash of 'Name' => value.
- #ext_attrs_clear_unsaved_changes ⇒ Object
- #ext_attrs_to_jamf ⇒ Object
- #ext_attrs_to_update ⇒ Object
- #ext_attrs_unsaved_changes ⇒ Object
- #ext_attrs_unsaved_changes? ⇒ Boolean
- #set_ext_attr(ea_name, new_val) ⇒ Object
Instance Method Details
#ext_attr_names ⇒ Object
37 38 39 |
# File 'lib/jamf/api/mixins/extendable.rb', line 37 def ext_attr_names extensionAttributes.map(&:name).freeze end |
#ext_attrs ⇒ Object
The Array of extensionAttributes converted to a Hash of 'Name' => value
33 34 35 |
# File 'lib/jamf/api/mixins/extendable.rb', line 33 def ext_attrs extensionAttributes.map { |ea| [ea.name, ea.value] }.to_h.freeze end |
#ext_attrs_clear_unsaved_changes ⇒ Object
65 66 67 |
# File 'lib/jamf/api/mixins/extendable.rb', line 65 def ext_attrs_clear_unsaved_changes ext_attrs_to_update.each(&:clear_unsaved_changes) end |
#ext_attrs_to_jamf ⇒ Object
69 70 71 |
# File 'lib/jamf/api/mixins/extendable.rb', line 69 def ext_attrs_to_jamf ext_attrs_to_update.map(&:to_jamf) end |
#ext_attrs_to_update ⇒ Object
47 48 49 |
# File 'lib/jamf/api/mixins/extendable.rb', line 47 def ext_attrs_to_update extensionAttributes.select(&:unsaved_changes?) end |
#ext_attrs_unsaved_changes ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/jamf/api/mixins/extendable.rb', line 51 def ext_attrs_unsaved_changes ext_attrs_to_update.map do |ea| [ea.name, { old: ea.unsaved_changes[:value][:old], new: ea.unsaved_changes[:value][:new] }] end.to_h end |
#ext_attrs_unsaved_changes? ⇒ Boolean
61 62 63 |
# File 'lib/jamf/api/mixins/extendable.rb', line 61 def ext_attrs_unsaved_changes? !ext_attrs_to_update.empty? end |
#set_ext_attr(ea_name, new_val) ⇒ Object
41 42 43 44 45 |
# File 'lib/jamf/api/mixins/extendable.rb', line 41 def set_ext_attr(ea_name, new_val) raise Jamf::NoSuchItemError, "No ext attr named '#{ea_name}'" unless ext_attr_names.include? ea_name eattr = extensionAttributes.select { |ea| ea.name == ea_name }.first eattr.send :new_value=, new_val end |