lib/jss/api_object.rb in ruby-jss-0.11.0b1 vs lib/jss/api_object.rb in ruby-jss-0.11.0b2

- old
+ new

@@ -481,11 +481,10 @@ raise ArgumentError, "Use '#{self.class}.fetch id: xx' to retrieve existing JSS objects" if args[:id] args[:id] = :new new args end - # Delete one or more API objects by jss_id without instantiating them. # Non-existent id's are skipped and an array of skipped ids is returned. # # If an Array is provided, it is passed through #uniq! before being processed. # @@ -503,11 +502,11 @@ raise JSS::InvalidDataError, 'Parameter must be an Integer ID or an Array of them' unless victims.is_a?(Integer) || victims.is_a?(Array) case victims when Integer victims = [victims] - when Fixnum + when Integer victims = [victims] when Array victims.uniq! end @@ -630,20 +629,18 @@ ###### Make a new one in the JSS, but only if we've included the Creatable module elsif args[:id] == :new validate_init_for_creation(args) setup_object_for_creation(args) - - return - + @need_to_update = true ###### Look up the data via the API else @init_data = look_up_object_data(args) + @need_to_update = false end ## end arg parsing parse_init_data - @need_to_update = false end # init # Public Instance Methods ##################################### @@ -966,13 +963,19 @@ # set empty strings to nil @init_data.jss_nillify! '', :recurse # Find the "main" subset which contains :id and :name @main_subset = find_main_subset - - @id = @main_subset[:id] @name = @main_subset[:name] - @in_jss = true + + if @main_subset[:id] == :new + @id = 0 + @in_jss = false + else + @id = @main_subset[:id] + @in_jss = true + end + @rest_rsrc = "#{self.class::RSRC_BASE}/id/#{@id}" # many things have a :site # TODO: Implement a Sitable mixin module #