Class: TFS::QueryEngine
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Includes:
- ClassHelpers
- Defined in:
- lib/tfs/query_engine.rb
Constant Summary
collapse
- VALID_CLASSES =
[
TFS::Builds,
TFS::Changesets,
TFS::Projects,
TFS::WorkItems
]
- DEFAULT_LIMIT =
50
ClassHelpers::SPECIAL_CASES
Instance Attribute Summary collapse
Instance Method Summary
collapse
#base_class, #method_name_from_class, #odata_class_from_method_name
Constructor Details
#initialize(for_class, connection, params = "") ⇒ QueryEngine
Returns a new instance of QueryEngine.
24
25
26
27
28
29
|
# File 'lib/tfs/query_engine.rb', line 24
def initialize(for_class, connection, params="")
check_type(for_class)
@type, @connection = for_class, connection
@native_query = @connection.send(base_class(for_class), normalize(params))
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
74
75
76
77
78
|
# File 'lib/tfs/query_engine.rb', line 74
def method_missing(method_name, *args, &block)
return super unless @type.send "#{method_name}?".to_sym
@native_query.navigate(odata_class_from_method_name(method_name))
self
end
|
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
13
14
15
|
# File 'lib/tfs/query_engine.rb', line 13
def type
@type
end
|
Instance Method Details
#count ⇒ Object
50
51
52
53
|
# File 'lib/tfs/query_engine.rb', line 50
def count
@native_query = @native_query.count
self
end
|
#include(klass) ⇒ Object
55
56
57
58
59
|
# File 'lib/tfs/query_engine.rb', line 55
def include(klass)
check_type(klass)
@native_query.expand(base_class(klass))
self
end
|
#limit(count) ⇒ Object
35
36
37
38
|
# File 'lib/tfs/query_engine.rb', line 35
def limit(count)
@native_query = @native_query.top(count)
self
end
|
#order_by(query) ⇒ Object
40
41
42
43
|
# File 'lib/tfs/query_engine.rb', line 40
def order_by(query)
@native_query = @native_query.order_by(query)
self
end
|
#page(start) ⇒ Object
61
62
63
64
|
# File 'lib/tfs/query_engine.rb', line 61
def page(start)
@native_query = @native_query.skip(start)
self
end
|
#raw ⇒ Object
31
32
33
|
# File 'lib/tfs/query_engine.rb', line 31
def raw
@native_query
end
|
#run ⇒ Object
66
67
68
|
# File 'lib/tfs/query_engine.rb', line 66
def run
@connection.execute
end
|
#to_query ⇒ Object
70
71
72
|
# File 'lib/tfs/query_engine.rb', line 70
def to_query
@native_query.query
end
|
#where(filter) ⇒ Object
45
46
47
48
|
# File 'lib/tfs/query_engine.rb', line 45
def where(filter)
@native_query = @native_query.filter(filter)
self
end
|