lib/jss/api_object/criteriable.rb in ruby-jss-1.2.4a4 vs lib/jss/api_object/criteriable.rb in ruby-jss-1.2.6

- old
+ new

@@ -150,24 +150,29 @@ # Classes mixing in this module must call this in #initialize # # @return [void] # def parse_criteria - @criteria = (JSS::Criteriable::Criteria.new @init_data[:criteria].map { |c| JSS::Criteriable::Criterion.new c } if @init_data[:criteria]) - @criteria.container = self if @criteria + @criteria = JSS::Criteriable::Criteria.new + @criteria.criteria = @init_data[:criteria].map { |c| JSS::Criteriable::Criterion.new c } if @init_data[:criteria] + + @criteria.container = self end # # Change the criteria, it must be a JSS::Criteriable::Criteria instance # - # @param new_criteria[JSS::Criteriable::Criteria] the new criteria + # @param new_criteria[JSS::Criteriable::Criteria, nil] the new criteria. An + # empty criteria object is used if nil is passed. # # @return [void] # def criteria=(new_criteria) + new_criteria ||= JSS::Criteriable::Criteria.new raise JSS::InvalidDataError, 'JSS::Criteriable::Criteria instance required' unless new_criteria.is_a?(JSS::Criteriable::Criteria) + @criteria = new_criteria - @criteria.container = self + @criteria.container = self unless new_criteria.nil? @need_to_update = true end # #