Class: OData::AbstractQuery::Segments::PropertySegment
Instance Attribute Summary collapse
#entity_type
#query, #value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Countable
included
#can_follow?, #inspect, segment_name
Constructor Details
#initialize(query, entity_type, property) ⇒ PropertySegment
Returns a new instance of PropertySegment.
18
19
20
21
22
|
# File 'lib/o_data/abstract_query/segments/property_segment.rb', line 18
def initialize(query, entity_type, property)
@property = property
super(query, entity_type, @property.name)
end
|
Instance Attribute Details
#property ⇒ Object
Returns the value of attribute property.
5
6
7
|
# File 'lib/o_data/abstract_query/segments/property_segment.rb', line 5
def property
@property
end
|
Class Method Details
.can_follow?(anOtherSegment) ⇒ Boolean
.parse!(query, str) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/o_data/abstract_query/segments/property_segment.rb', line 7
def self.parse!(query, str)
return nil if query.segments.empty?
return nil unless query.segments.last.respond_to?(:entity_type)
entity_type = query.segments.last.entity_type
return nil if entity_type.nil?
property = entity_type.properties.find { |p| p.name == str }
return nil if property.blank?
query.Segment(self, entity_type, property)
end
|
Instance Method Details
#countable? ⇒ Boolean
32
33
34
|
# File 'lib/o_data/abstract_query/segments/property_segment.rb', line 32
def countable?
false
end
|
#execute!(acc) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/o_data/abstract_query/segments/property_segment.rb', line 36
def execute!(acc)
{ @property => @property.value_for([acc].flatten.compact.first) }
end
|
#valid?(results) ⇒ Boolean
43
44
45
46
|
# File 'lib/o_data/abstract_query/segments/property_segment.rb', line 43
def valid?(results)
!results.blank?
end
|