Class: OData::AbstractQuery::Segments::CountSegment
- Inherits:
-
OData::AbstractQuery::Segment
- Object
- OData::AbstractQuery::Segment
- OData::AbstractQuery::Segments::CountSegment
- Defined in:
- lib/o_data/abstract_query/segments/count_segment.rb
Instance Attribute Summary
Attributes inherited from OData::AbstractQuery::Segment
Class Method Summary collapse
Instance Method Summary collapse
- #execute!(acc) ⇒ Object
-
#initialize(query) ⇒ CountSegment
constructor
A new instance of CountSegment.
- #valid?(results) ⇒ Boolean
Methods inherited from OData::AbstractQuery::Segment
Constructor Details
#initialize(query) ⇒ CountSegment
Returns a new instance of CountSegment.
15 16 17 |
# File 'lib/o_data/abstract_query/segments/count_segment.rb', line 15 def initialize(query) super(query, self.class.segment_name) end |
Class Method Details
.can_follow?(anOtherSegment) ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/o_data/abstract_query/segments/count_segment.rb', line 19 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 |
.parse!(query, str) ⇒ Object
5 6 7 8 9 |
# File 'lib/o_data/abstract_query/segments/count_segment.rb', line 5 def self.parse!(query, str) return nil unless str.to_s == segment_name query.Segment(self) end |
.segment_name ⇒ Object
11 12 13 |
# File 'lib/o_data/abstract_query/segments/count_segment.rb', line 11 def self.segment_name "$count" end |
Instance Method Details
#execute!(acc) ⇒ Object
27 28 29 30 |
# File 'lib/o_data/abstract_query/segments/count_segment.rb', line 27 def execute!(acc) return acc.length if acc.respond_to?(:length) 1 end |
#valid?(results) ⇒ Boolean
32 33 34 |
# File 'lib/o_data/abstract_query/segments/count_segment.rb', line 32 def valid?(results) results.is_a?(Fixnum) end |