class FrOData::Query::Criteria
Represents a discreet criteria within an FrOData::Query
. Should not, normally, be instantiated directly.
Attributes
argument[R]
An optional argument to the function.
function[R]
A function to apply to the property.
operator[R]
The operator of the criteria.
property[R]
The property name that is the target of the criteria.
value[R]
The value of the criteria.
Public Class Methods
new(options = {})
click to toggle source
Initializes a new criteria with provided options. @param options [Hash]
# File lib/frodata/query/criteria.rb, line 25 def initialize(options = {}) @property = options[:property] @operator = options[:operator] @function = options[:function] @argument = options[:argument] @value = options[:value] end
Public Instance Methods
to_s()
click to toggle source
Returns criteria as query-ready string.
# File lib/frodata/query/criteria.rb, line 40 def to_s query = function ? function_expression : property_name if operator && !lambda_operator? "#{query} #{operator} #{url_value(value)}" else query end end
Private Instance Methods
function_expression()
click to toggle source
# File lib/frodata/query/criteria.rb, line 58 def function_expression return lambda_expression if lambda_operator? if argument "#{function}(#{property_name},#{url_value(argument)})" else "#{function}(#{property_name})" end end
lambda_expression()
click to toggle source
# File lib/frodata/query/criteria.rb, line 68 def lambda_expression "#{property_name}/#{function}(d:d/#{argument} #{operator} #{url_value(value)})" end
property_name()
click to toggle source
# File lib/frodata/query/criteria.rb, line 52 def property_name property.name rescue NoMethodError property.to_s end
set_function_and_argument(function, argument)
click to toggle source
# File lib/frodata/query/criteria.rb, line 85 def set_function_and_argument(function, argument) @function = function @argument = argument self end
set_operator_and_value(operator, value)
click to toggle source
# File lib/frodata/query/criteria.rb, line 79 def set_operator_and_value(operator, value) @operator = operator @value = value self end
url_value(value)
click to toggle source
# File lib/frodata/query/criteria.rb, line 72 def url_value(value) property.value = value property.url_value rescue value end