lib/zendesk_api/collection.rb
# Executes actual GET from API and loads resources into proper class.
# @param [Boolean] reload Whether to disregard cache
Executes actual GET from API and loads resources into proper class.
Executes actual GET from API and loads resources into proper class .
def fetch(reload = false)
      return @resources if @resources && (!@fetchable || !reload)
      if association && association.options.parent && association.options.parent.new_record?
        return @resources = []
      end
      if @query
        path = @query
        @query = nil
      else
        path = self.path
      end
      response = @client.connection.send(@verb || "get", path) do |req|
        req.params.merge!(@options.delete_if {|k, v| v.nil?})
      end
      results = response.body[@resource_class.model_key] || response.body["results"]
      @resources = results.map { |res| @resource_class.new(@client, res) }
      @count = (response.body["count"] || @resources.size).to_i
      @next_page, @prev_page = response.body["next_page"], response.body["previous_page"]
      @resources
    end
def fetch ( reload = false ) return @resources if @resources && ( ! @fetchable || ! reload ) if association && association . options . parent && association . options . parent . new_record? return @resources = [ ] end if @query path = @query @query = nil else path = self . path end response = @client . connection . send ( @verb || "get" , path ) do | req | req . params . merge! ( @options . delete_if { | k , v | v . nil? } ) end results = response . body [ @resource_class . model_key ] || response . body [ "results" ] @resources = results . map { | res | @resource_class . new ( @client , res ) } @count = ( response . body [ "count" ] || @resources . size ) . to_i @next_page , @prev_page = response . body [ "next_page" ] , response . body [ "previous_page" ] @resources end
Executes actual GET from API and loads resources into proper class.
Executes actual GET from API and loads resources into proper class .
reload
<not_specific>
<not_specific>
reload Whether to disregard cache
reload Whether to disregard cache