lib/jss/api_object/script.rb in ruby-jss-0.7.0 vs lib/jss/api_object/script.rb in ruby-jss-0.8.1

- old
+ new

@@ -59,10 +59,11 @@ ### Mix-Ins ##################################### include JSS::Creatable include JSS::Updatable + include JSS::Categorizable ### Class Methods ##################################### ### Class Constants @@ -125,11 +126,10 @@ ### def initialize(args = {}) super - @category = JSS::APIObject.get_name(@init_data[:category]) @filename = @init_data[:filename] || @name @info = @init_data[:info] @notes = @init_data[:notes] @os_requirements = @init_data[:os_requirements] ? JSS.to_s_and_a(@init_data[:os_requirements])[:arrayform] : [] @parameters = @init_data[:parameters] ? @init_data[:parameters] : {} @@ -261,25 +261,10 @@ new_val = new_val.to_s.tr("\n", "\r") @notes = new_val @need_to_update = true end # notes= - ### Change the category - ### - ### @param new_val[String] the name of the new category, which must be in {JSS::Category.all_names} - ### - ### @return [void] - ### - def category=(new_val) - return nil if new_val == @category - new_val = nil if new_val == '' - new_val ||= JSS::Category::DEFAULT_CATEGORY - raise JSS::InvalidDataError, "Category #{new_val} is not known to the JSS" unless JSS::Category.all_names.include? new_val - @need_to_update = true - @category = new_val - end # category= - ### Replace all the script parameters at once. ### ### This will replace the entire set with the hash provided. ### ### @param new_val[Hash] the Hash keys must exist in {PARAMETER_KEYS} @@ -568,17 +553,18 @@ ### Return the xml for creating or updating this script in the JSS ### def rest_xml doc = REXML::Document.new scpt = doc.add_element 'script' - scpt.add_element('category').text = @category + scpt.add_element('filename').text = @filename scpt.add_element('id').text = @id scpt.add_element('info').text = @info scpt.add_element('name').text = @name scpt.add_element('notes').text = @notes scpt.add_element('os_requirements').text = JSS.to_s_and_a(@os_requirements)[:stringform] scpt.add_element('priority').text = @priority + add_category_to_xml(doc) if @parameters.empty? scpt.add_element('parameters').text = nil else pars = scpt.add_element('parameters')