Class: Atomsphere::Query::GroupingExpression
- Inherits:
-
Expression
- Object
- Expression
- Atomsphere::Query::GroupingExpression
- Defined in:
- lib/atomsphere/query/expression/grouping_expression.rb
Overview
Constant Summary collapse
- OPERATORS =
allowed values for #operator=
:and, :or
Instance Attribute Summary collapse
-
#nested_expression ⇒ Object
Returns the value of attribute nested_expression.
-
#operator ⇒ Object
Returns the value of attribute operator.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ GroupingExpression
constructor
A new instance of GroupingExpression.
-
#to_hash ⇒ Hash
returns a hash of the expression that will be sent to the boomi api with #to_hash.
-
#validate! ⇒ true, false
run all ‘validate_*!` private methods to ensure validity of expression parameters.
Constructor Details
#initialize(params = {}) ⇒ GroupingExpression
Returns a new instance of GroupingExpression.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/atomsphere/query/expression/grouping_expression.rb', line 16 def initialize(params={}) case params when String when Symbol params = {operator: params} end params = { operator: :and, nested_expression: [] }.merge(params) @operator = params[:operator] @nested_expression = params[:nested_expression] end |
Instance Attribute Details
#nested_expression ⇒ Object
Returns the value of attribute nested_expression.
8 9 10 |
# File 'lib/atomsphere/query/expression/grouping_expression.rb', line 8 def nested_expression @nested_expression end |
#operator ⇒ Object
Returns the value of attribute operator.
8 9 10 |
# File 'lib/atomsphere/query/expression/grouping_expression.rb', line 8 def operator @operator end |
Instance Method Details
#to_hash ⇒ Hash
returns a hash of the expression that will be sent to the boomi api with Atomsphere::Query#to_hash
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/atomsphere/query/expression/grouping_expression.rb', line 52 def to_hash { expression: { operator: operator.to_s, nestedExpression: nested_expression. map(&:to_hash). map{ |h| h[:expression] } } } end |
#validate! ⇒ true, false
run all ‘validate_*!` private methods to ensure validity of expression parameters
42 43 44 45 46 47 |
# File 'lib/atomsphere/query/expression/grouping_expression.rb', line 42 def validate! private_methods.select{ |m| m =~ /^validate_[a-z0-9_]+\!$/ }.each{ |v| "#{v}"; send(v) } @nested_expression.each(&:validate!) true end |