Class: JsonApiServer::SqlComp
- Inherits:
-
FilterBuilder
- Object
- FilterBuilder
- JsonApiServer::SqlComp
- Defined in:
- lib/json_api_server/filter_builders.rb
Overview
Query comparison builder, .i.e., where(‘id > ?’, ‘22’).
Instance Attribute Summary
Attributes inherited from FilterBuilder
#attr, #column_name, #config, #operator, #value
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from FilterBuilder
Constructor Details
This class inherits a constructor from JsonApiServer::FilterBuilder
Class Method Details
.allowed_operators ⇒ Object
68 69 70 |
# File 'lib/json_api_server/filter_builders.rb', line 68 def self.allowed_operators ['=', '<', '>', '>=', '<=', '!='] end |
Instance Method Details
#to_query(model) ⇒ Object
72 73 74 75 76 |
# File 'lib/json_api_server/filter_builders.rb', line 72 def to_query(model) if self.class.allowed_operators.include?(operator) model.where("#{full_column_name(model)} #{operator} ?", value) end end |