Class: OData::AbstractQuery::Parser
- Inherits:
-
Object
- Object
- OData::AbstractQuery::Parser
- Defined in:
- lib/o_data/abstract_query/parser.rb
Constant Summary collapse
- @@reserved_option_names =
%w{orderby expand select top skip filter format inlinecount}.freeze
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
-
#initialize(schema) ⇒ Parser
constructor
A new instance of Parser.
- #parse!(uri) ⇒ Object
Constructor Details
#initialize(schema) ⇒ Parser
Returns a new instance of Parser.
9 10 11 |
# File 'lib/o_data/abstract_query/parser.rb', line 9 def initialize(schema) @schema = schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
7 8 9 |
# File 'lib/o_data/abstract_query/parser.rb', line 7 def schema @schema end |
Instance Method Details
#parse!(uri) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/o_data/abstract_query/parser.rb', line 13 def parse!(uri) return nil if uri.blank? query = @schema.Query resource_path, query_string = uri.split('?', 2) unless resource_path.blank? resource_path_components = resource_path.split('/') resource_path_components.each_index do |i| resource_path_component = resource_path_components[i] segment = _parse_segment!(query, resource_path_component) end end unless query_string.blank? query_string_components = query_string.split('&') query_string_components.each_index do |i| query_string_component = query_string_components[i] option = _parse_option!(query, query_string_component) end end query end |