class Easy::Resources::Redmine::RedmineBase
Public Class Methods
configure(conf = nil)
click to toggle source
@param [Hash, nil] conf
Calls superclass method
Easy::Resource::configure
# File lib/easy/resources/redmine/redmine_base.rb, line 14 def configure(conf = nil) conf ||= ::Easy.config.sites.redmine self.api_key = conf[:api_key] super(conf) end
get_all(**params, &block)
click to toggle source
# File lib/easy/resources/redmine/redmine_base.rb, line 34 def get_all(**params, &block) records = results = all(params: params) response = results.http_response total = retrieve_total(response) current_page = 1 while records.any? records.each(&block) if block_given? break if results.size >= total self.format = :xml records = all(params: params.merge(page: (current_page += 1))) results.concat(records) end results end
headers()
click to toggle source
Calls superclass method
# File lib/easy/resources/redmine/redmine_base.rb, line 22 def headers h = super h['X-Redmine-API-Key'] = api_key h end
retrieve_total(response)
click to toggle source
Parse value of TOTAL amount of entities from headers or response @return [Integer]
# File lib/easy/resources/redmine/redmine_base.rb, line 30 def retrieve_total(response) (response['Total'] || response.body[/total_count[:="]+(\d+)/] && Regexp.last_match(1)).to_i end
Public Instance Methods
errors()
click to toggle source
# File lib/easy/resources/redmine/redmine_base.rb, line 55 def errors @errors ||= Errors.new(self) end