Class: CriteriaOperator::GroupOperator
- Inherits:
-
BaseOperator
- Object
- BaseOperator
- CriteriaOperator::GroupOperator
- Defined in:
- lib/criteria_operator/group_operator.rb
Overview
Operator that groups multiple operators using one grouping type.
Instance Attribute Summary collapse
-
#operand_collection ⇒ Array<BaseOperator>
The collection of operands grouped by this operator.
-
#operator_type ⇒ GroupOperatorType
The type of this operator.
Instance Method Summary collapse
-
#clone ⇒ GroupOperator
Clones an operator with all sub-operators, creating a deep copy.
-
#initialize(operands = [], group_operator_type = GroupOperatorType::AND) ⇒ Void
constructor
The constructor for this operator.
Methods inherited from BaseOperator
deserialize, serialize, #serialize
Constructor Details
#initialize(operands = [], group_operator_type = GroupOperatorType::AND) ⇒ Void
The constructor for this operator. Expects a collection of operands and the operator type as parameters.
26 27 28 29 |
# File 'lib/criteria_operator/group_operator.rb', line 26 def initialize(operands = [], group_operator_type = GroupOperatorType::AND) self.operand_collection = operands self.operator_type = group_operator_type end |
Instance Attribute Details
#operand_collection ⇒ Array<BaseOperator>
Returns the collection of operands grouped by this operator.
20 21 22 |
# File 'lib/criteria_operator/group_operator.rb', line 20 def operand_collection @operand_collection end |
#operator_type ⇒ GroupOperatorType
Returns the type of this operator.
17 18 19 |
# File 'lib/criteria_operator/group_operator.rb', line 17 def operator_type @operator_type end |
Instance Method Details
#clone ⇒ GroupOperator
Clones an operator with all sub-operators, creating a deep copy. Implementation of the abstract BaseOperator#clone.
34 35 36 37 38 |
# File 'lib/criteria_operator/group_operator.rb', line 34 def clone ops = [] self.operand_collection.each { |op| ops << clone_or_nil(op) } GroupOperator.new ops, self.operator_type end |