Class: OData::AbstractQuery::Segments::EntityTypeSegment

Inherits:
OData::AbstractQuery::Segment show all
Includes:
Countable
Defined in:
lib/o_data/abstract_query/segments/entity_type_segment.rb

Instance Attribute Summary collapse

Attributes inherited from OData::AbstractQuery::Segment

#query, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Countable

included

Methods inherited from OData::AbstractQuery::Segment

#can_follow?, #inspect, parse!, segment_name

Constructor Details

#initialize(query, entity_type, value = nil) ⇒ EntityTypeSegment

Returns a new instance of EntityTypeSegment.



9
10
11
12
13
# File 'lib/o_data/abstract_query/segments/entity_type_segment.rb', line 9

def initialize(query, entity_type, value = nil)
  @entity_type = entity_type

  super(query, value || (@entity_type.is_a?(OData::AbstractSchema::EntityType) ? @entity_type.plural_name : @entity_type))
end

Instance Attribute Details

#entity_typeObject (readonly)

Returns the value of attribute entity_type.



7
8
9
# File 'lib/o_data/abstract_query/segments/entity_type_segment.rb', line 7

def entity_type
  @entity_type
end

Class Method Details

.can_follow?(anOtherSegment) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/o_data/abstract_query/segments/entity_type_segment.rb', line 15

def self.can_follow?(anOtherSegment)
  false
end

Instance Method Details

#execute!(acc) ⇒ Object



19
20
21
22
23
# File 'lib/o_data/abstract_query/segments/entity_type_segment.rb', line 19

def execute!(acc)
  return [] if @entity_type.blank?

  @entity_type.find_all
end

#valid?(results) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/o_data/abstract_query/segments/entity_type_segment.rb', line 25

def valid?(results)
  countable? ? results.is_a?(Array) : !results.blank?
end