Class: OData::AbstractQuery::Segments::LinksSegment
- Inherits:
-
OData::AbstractQuery::Segment
- Object
- OData::AbstractQuery::Segment
- OData::AbstractQuery::Segments::LinksSegment
- Includes:
- Countable
- Defined in:
- lib/o_data/abstract_query/segments/links_segment.rb
Instance Attribute Summary
Attributes inherited from OData::AbstractQuery::Segment
Class Method Summary collapse
- .can_follow?(anOtherSegment) ⇒ Boolean
- .countable? ⇒ Boolean
- .parse!(query, str) ⇒ Object
- .segment_name ⇒ Object
Instance Method Summary collapse
- #execute!(acc) ⇒ Object
-
#initialize(query) ⇒ LinksSegment
constructor
A new instance of LinksSegment.
- #valid?(results) ⇒ Boolean
Methods included from Countable
Methods inherited from OData::AbstractQuery::Segment
Constructor Details
#initialize(query) ⇒ LinksSegment
Returns a new instance of LinksSegment.
21 22 23 |
# File 'lib/o_data/abstract_query/segments/links_segment.rb', line 21 def initialize(query) super(query, self.class.segment_name) end |
Class Method Details
.can_follow?(anOtherSegment) ⇒ Boolean
25 26 27 28 29 30 31 |
# File 'lib/o_data/abstract_query/segments/links_segment.rb', line 25 def self.can_follow?(anOtherSegment) if anOtherSegment.is_a?(Class) anOtherSegment == CollectionSegment || anOtherSegment == NavigationPropertySegment else (anOtherSegment.is_a?(CollectionSegment) || anOtherSegment.is_a?(NavigationPropertySegment)) # && anOtherSegment.countable? end end |
.countable? ⇒ Boolean
17 18 19 |
# File 'lib/o_data/abstract_query/segments/links_segment.rb', line 17 def self.countable? true end |
.parse!(query, str) ⇒ Object
7 8 9 10 11 |
# File 'lib/o_data/abstract_query/segments/links_segment.rb', line 7 def self.parse!(query, str) return nil unless str.to_s == segment_name query.Segment(self) end |
.segment_name ⇒ Object
13 14 15 |
# File 'lib/o_data/abstract_query/segments/links_segment.rb', line 13 def self.segment_name "$links" end |
Instance Method Details
#execute!(acc) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/o_data/abstract_query/segments/links_segment.rb', line 33 def execute!(acc) [acc].flatten.compact.collect { |one| if entity_type = self.query.schema.entity_types.find { |et| et.name == one.class.name } [one, entity_type.plural_name + '(' + entity_type.primary_key_for(one).to_s + ')'] else [one, nil] end } end |
#valid?(results) ⇒ Boolean
43 44 45 |
# File 'lib/o_data/abstract_query/segments/links_segment.rb', line 43 def valid?(results) results.all? { |pair| !pair[1].blank? } end |