Class: Scimaenaga::ScimQueryParser
- Inherits:
-
Object
- Object
- Scimaenaga::ScimQueryParser
- Defined in:
- app/models/scimaenaga/scim_query_parser.rb
Instance Attribute Summary collapse
-
#query_attributes ⇒ Object
Returns the value of attribute query_attributes.
-
#query_elements ⇒ Object
Returns the value of attribute query_elements.
Instance Method Summary collapse
- #attribute ⇒ Object
-
#initialize(query_string, queryable_attributes) ⇒ ScimQueryParser
constructor
A new instance of ScimQueryParser.
- #operator ⇒ Object
- #parameter ⇒ Object
Constructor Details
#initialize(query_string, queryable_attributes) ⇒ ScimQueryParser
Returns a new instance of ScimQueryParser.
7 8 9 10 |
# File 'app/models/scimaenaga/scim_query_parser.rb', line 7 def initialize(query_string, queryable_attributes) self.query_elements = query_string.gsub(/\[(.+?)\]/, '.0').split self.query_attributes = queryable_attributes end |
Instance Attribute Details
#query_attributes ⇒ Object
Returns the value of attribute query_attributes.
5 6 7 |
# File 'app/models/scimaenaga/scim_query_parser.rb', line 5 def query_attributes @query_attributes end |
#query_elements ⇒ Object
Returns the value of attribute query_elements.
5 6 7 |
# File 'app/models/scimaenaga/scim_query_parser.rb', line 5 def query_elements @query_elements end |
Instance Method Details
#attribute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/scimaenaga/scim_query_parser.rb', line 12 def attribute attribute = query_elements[0] raise Scimaenaga::ExceptionHandler::InvalidQuery if attribute.blank? dig_keys = attribute.split('.').map do |step| step == '0' ? 0 : step.to_sym end mapped_attribute = query_attributes.dig(*dig_keys) raise Scimaenaga::ExceptionHandler::InvalidQuery if mapped_attribute.blank? mapped_attribute end |
#operator ⇒ Object
26 27 28 |
# File 'app/models/scimaenaga/scim_query_parser.rb', line 26 def operator sql_comparison_operator(query_elements[1]) end |
#parameter ⇒ Object
30 31 32 33 34 35 |
# File 'app/models/scimaenaga/scim_query_parser.rb', line 30 def parameter parameter = query_elements[2..-1].join(' ') return if parameter.blank? parameter.gsub(/"/, '') end |