Class: OData::AbstractQuery::Base
- Inherits:
-
Object
- Object
- OData::AbstractQuery::Base
- Defined in:
- lib/o_data/abstract_query/base.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(schema, segments = [], options = []) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #Option(*args) ⇒ Object
- #query_string ⇒ Object
- #resource_path ⇒ Object
- #Segment(*args) ⇒ Object
- #to_uri ⇒ Object
Constructor Details
#initialize(schema, segments = [], options = []) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 |
# File 'lib/o_data/abstract_query/base.rb', line 7 def initialize(schema, segments = [], = []) @schema = schema @segments = segments @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/o_data/abstract_query/base.rb', line 5 def @options end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
4 5 6 |
# File 'lib/o_data/abstract_query/base.rb', line 4 def schema @schema end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
5 6 7 |
# File 'lib/o_data/abstract_query/base.rb', line 5 def segments @segments end |
Instance Method Details
#execute! ⇒ Object
60 61 62 |
# File 'lib/o_data/abstract_query/base.rb', line 60 def execute! _execute! end |
#inspect ⇒ Object
14 15 16 |
# File 'lib/o_data/abstract_query/base.rb', line 14 def inspect "#<< #{@schema.namespace.to_s}(#{self.to_uri.inspect}) >>" end |
#Option(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/o_data/abstract_query/base.rb', line 33 def Option(*args) option_class = begin if args.first.is_a?(Symbol) || args.first.is_a?(String) "OData::AbstractQuery::Options::#{args.shift.to_s}Option".constantize else args.shift end end option = option_class.new(self, *args) @options << option option end |
#query_string ⇒ Object
52 53 54 |
# File 'lib/o_data/abstract_query/base.rb', line 52 def query_string @options.collect { |o| "#{o.key.to_s}=#{o.value.to_s}" }.join('&') end |
#resource_path ⇒ Object
48 49 50 |
# File 'lib/o_data/abstract_query/base.rb', line 48 def resource_path @segments.collect(&:value).join('/') end |
#Segment(*args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/o_data/abstract_query/base.rb', line 18 def Segment(*args) segment_class = begin if args.first.is_a?(Symbol) || args.first.is_a?(String) "OData::AbstractQuery::Segments::#{args.shift.to_s}Segment".constantize else args.shift end end segment = segment_class.new(self, *args) @segments << segment segment end |
#to_uri ⇒ Object
56 57 58 |
# File 'lib/o_data/abstract_query/base.rb', line 56 def to_uri [resource_path, query_string].reject(&:blank?).join('?') end |