Class: Redmine::Cli::BaseResource

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/redmine-cli/resources.rb

Direct Known Subclasses

Issue, Project, Query, User

Class Method Summary collapse

Class Method Details

.fetch_all(params = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/redmine-cli/resources.rb', line 26

def fetch_all(params = {})
  limit  = 100
  offset = 0

  resources = []

  while((fetched_resources = self.all(:params => params.merge({:limit => limit, :offset => offset}))).any?)
    resources += fetched_resources
    offset    += limit
    if fetched_resources.length < limit then
      break
    end
  end

  resources
end

.find(*arguments) ⇒ Object

HACK: Redmine API isn’t ActiveResource-friendly out of the box, so we need to pass nometa=1 to all requests since we don’t care about the metadata that gets passed back in the top level attributes.



18
19
20
21
22
23
24
# File 'lib/redmine-cli/resources.rb', line 18

def find(*arguments)
  arguments[1] = arguments[1] || {}
  arguments[1][:params] = arguments[1][:params] || {}
  arguments[1][:params][:nometa] = 1

  super
end