Class: OData::AbstractQuery::Options::ExpandOption
- Inherits:
-
OData::AbstractQuery::Option
- Object
- BasicOption
- OData::AbstractQuery::Option
- OData::AbstractQuery::Options::ExpandOption
- Defined in:
- lib/o_data/abstract_query/options/expand_option.rb
Instance Attribute Summary collapse
-
#navigation_property_paths ⇒ Object
readonly
Returns the value of attribute navigation_property_paths.
-
#navigation_property_paths_str ⇒ Object
readonly
Returns the value of attribute navigation_property_paths_str.
Attributes inherited from BasicOption
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(query, navigation_property_paths = {}, navigation_property_paths_str = nil) ⇒ ExpandOption
constructor
TODO: remove navigation_property_paths_str.
- #valid? ⇒ Boolean
- #value ⇒ Object
Methods inherited from OData::AbstractQuery::Option
Methods inherited from BasicOption
Constructor Details
#initialize(query, navigation_property_paths = {}, navigation_property_paths_str = nil) ⇒ ExpandOption
TODO: remove navigation_property_paths_str
12 13 14 15 16 17 |
# File 'lib/o_data/abstract_query/options/expand_option.rb', line 12 def initialize(query, = {}, = nil) @navigation_property_paths = @navigation_property_paths_str = super(query, self.class.option_name) end |
Instance Attribute Details
#navigation_property_paths ⇒ Object (readonly)
Returns the value of attribute navigation_property_paths.
9 10 11 |
# File 'lib/o_data/abstract_query/options/expand_option.rb', line 9 def @navigation_property_paths end |
#navigation_property_paths_str ⇒ Object (readonly)
Returns the value of attribute navigation_property_paths_str.
9 10 11 |
# File 'lib/o_data/abstract_query/options/expand_option.rb', line 9 def @navigation_property_paths_str end |
Class Method Details
.applies_to?(query) ⇒ Boolean
19 20 21 22 |
# File 'lib/o_data/abstract_query/options/expand_option.rb', line 19 def self.applies_to?(query) return false if query.segments.empty? (query.segments.last.is_a?(OData::AbstractQuery::Segments::CollectionSegment) || query.segments.last.is_a?(OData::AbstractQuery::Segments::NavigationPropertySegment)) end |
.option_name ⇒ Object
5 6 7 |
# File 'lib/o_data/abstract_query/options/expand_option.rb', line 5 def self.option_name '$expand' end |
.parse!(query, key, value = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/o_data/abstract_query/options/expand_option.rb', line 24 def self.parse!(query, key, value = nil) return nil unless key == self.option_name if query.segments.last.respond_to?(:navigation_property) = query.segments.last. raise OData::AbstractQuery::Errors::InvalidOptionValue.new(query, self.option_name) if .to_end.polymorphic? end if query.segments.last.respond_to?(:entity_type) entity_type = query.segments.last.entity_type = value.to_s.split(/\s*,\s*/).inject({}) { |acc, path| segments = path.split('/') (query, acc, entity_type, segments.shift, segments) acc } query.Option(self, , value.to_s) else raise OData::AbstractQuery::Errors::InvalidOptionContext.new(query, self.option_name) unless value.blank? end end |
Instance Method Details
#valid? ⇒ Boolean
48 49 50 51 |
# File 'lib/o_data/abstract_query/options/expand_option.rb', line 48 def valid? # TODO: replace with validation true end |
#value ⇒ Object
53 54 55 |
# File 'lib/o_data/abstract_query/options/expand_option.rb', line 53 def value "'" + @navigation_property_paths_str.gsub(/\s+/, '') + "'" end |