Class: TFS::Queryable

Inherits:
Object
  • Object
show all
Extended by:
ClassHelpers
Defined in:
lib/tfs/queryable.rb

Direct Known Subclasses

Builds, Changes, Changesets, Projects, WorkItems

Constant Summary collapse

RecordNotFound =
Class.new(StandardError)

Constants included from ClassHelpers

ClassHelpers::SPECIAL_CASES

Class Method Summary collapse

Methods included from ClassHelpers

base_class, method_name_from_class, odata_class_from_method_name

Class Method Details

.allObject

Always limit to the default limit of 50 so as not to overwhelm the service If more are required, set ‘#limit` explicitly.



9
10
11
# File 'lib/tfs/queryable.rb', line 9

def all
  get_query.limit(QueryEngine::DEFAULT_LIMIT).run
end

.inherited(klass) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tfs/queryable.rb', line 13

def inherited(klass)
  klass.instance_eval do
    @children = []

    def add_child(child_class)

      base = method_name_from_class(child_class).to_sym
      self.send(:define_singleton_method, "#{base}?") { true }
    end
  end
end

.odata_query(raw_query) ⇒ Object Also known as: where

#odata_query allows you to access the raw query sytax provide by the OData api

TFS::Builds.odata_query('Status eq "Succeeded"')


29
30
31
# File 'lib/tfs/queryable.rb', line 29

def odata_query(raw_query)
  get_query.where(raw_query)
end