Class: Atomsphere::Query::SimpleExpression
- Inherits:
-
Expression
- Object
- Expression
- Atomsphere::Query::SimpleExpression
- Defined in:
- lib/atomsphere/query/expression/simple_expression.rb
Overview
Constant Summary collapse
- OPERATORS =
allowed values for #operator=
{ equals: 1, like: 1, not_equals: 1, is_null: 0, is_not_null: 0, starts_with: 1, between: 2, greater_than: 1, less_than: 1, greater_than_or_equal: 1, less_than_or_equal: 1 }
Instance Attribute Summary collapse
-
#argument ⇒ Object
Returns the value of attribute argument.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#property ⇒ Object
Returns the value of attribute property.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ SimpleExpression
constructor
A new instance of SimpleExpression.
-
#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 = {}) ⇒ SimpleExpression
Returns a new instance of SimpleExpression.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/atomsphere/query/expression/simple_expression.rb', line 29 def initialize(params={}) params = { operator: :equals, property: nil, argument: [] }.merge(params) %w(operator property argument).each do |v| send :"#{v}=", params[v.to_sym] end end |
Instance Attribute Details
#argument ⇒ Object
Returns the value of attribute argument.
8 9 10 |
# File 'lib/atomsphere/query/expression/simple_expression.rb', line 8 def argument @argument end |
#operator ⇒ Object
Returns the value of attribute operator.
8 9 10 |
# File 'lib/atomsphere/query/expression/simple_expression.rb', line 8 def operator @operator end |
#property ⇒ Object
Returns the value of attribute property.
8 9 10 |
# File 'lib/atomsphere/query/expression/simple_expression.rb', line 8 def property @property 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
65 66 67 68 69 70 71 72 73 |
# File 'lib/atomsphere/query/expression/simple_expression.rb', line 65 def to_hash { expression: { operator: operator.to_s.upcase, property: property.to_s, argument: [*argument].map(&:to_s) } } end |
#validate! ⇒ true, false
run all ‘validate_*!` private methods to ensure validity of expression parameters
57 58 59 60 |
# File 'lib/atomsphere/query/expression/simple_expression.rb', line 57 def validate! private_methods.select{ |m| m =~ /^validate_[a-z0-9_]+\!$/ }.each{ |v| send(v) } true end |