Module: JSS::Criteriable
- Included in:
- AdvancedSearch, Group
- Defined in:
- lib/jss.rb,
lib/jss/api_object/criteriable.rb,
lib/jss/api_object/criteriable/criteria.rb,
lib/jss/api_object/criteriable/criterion.rb
Overview
A mix-in module that allows objects to handle standardized search Criteria.
Some objects in the JSS, such as Advanced Searches and Smart Groups, include a set of Criteria. (i.e conditions which, when met, signify inclusion in a result set.)
A Criteria instance is a container for one or more Criterion instances and provides methods for dealing with them easily.
When a APIObject subclass includes this module, that subclass will have a :criteria attribute, which holds a Criteria object and can be used to manipulate the Criterion objects inside.
The including subclass also gains some instance methods:
-
#parse_critera - sets up the :criteria attribute during initialization
-
#criteria= - allows the wholesale replacement of the criteria
-
#need_to_update - allows the Criteria instance to inform the subclass instance that it has changed and needs an #update
Classes mixing in this module must
-
If they are Updatable or Creatable, they must insert self.criteria.rest_xml into their own xml output.
Defined Under Namespace
Constant Summary collapse
- CRITERIABLE =
Constants
true
Instance Attribute Summary collapse
-
#criteria ⇒ JSS::Criteriable::Criteria
The criteria for the instance into which we're mixed.
Instance Method Summary collapse
-
#parse_criteria ⇒ void
During initialization, convert the @init_data Hash into a JSS::Criteriable::Criteria instance stored in @criteria.
-
#should_update ⇒ void
private
Allow our Criteria to tell us when there's been a change that needs to be updated.
Instance Attribute Details
#criteria ⇒ JSS::Criteriable::Criteria
Returns the criteria for the instance into which we're mixed.
141 142 143 |
# File 'lib/jss/api_object/criteriable.rb', line 141 def criteria @criteria end |
Instance Method Details
#parse_criteria ⇒ void
This method returns an undefined value.
During initialization, convert the @init_data Hash into a JSS::Criteriable::Criteria instance stored in @criteria
Classes mixing in this module must call this in #initialize
154 155 156 157 158 159 |
# File 'lib/jss/api_object/criteriable.rb', line 154 def parse_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 |
#should_update ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Allow our Criteria to tell us when there's been a change that needs to be updated.
186 187 188 |
# File 'lib/jss/api_object/criteriable.rb', line 186 def should_update @need_to_update = true if @in_jss end |