lib/zendesk_api/collection.rb in zendesk_api-1.13.4 vs lib/zendesk_api/collection.rb in zendesk_api-1.14.0
- old
+ new
@@ -46,11 +46,11 @@
end
end
# Methods that take a Hash argument
methods = %w{create find update update_many destroy}
- methods += methods.map {|method| method + "!"}
+ methods += methods.map { |method| method + "!" }
methods.each do |deferrable|
# Passes arguments and the proper path to the resource class method.
# @param [Hash] options Options or attributes to pass
define_method deferrable do |*args|
unless @resource_class.respond_to?(deferrable)
@@ -150,11 +150,11 @@
end
# Adds an item (or items) to the list of side-loaded resources to request
# @option sideloads [Symbol or String] The item(s) to sideload
def include(*sideloads)
- self.tap { @includes.concat(sideloads.map(&:to_s)) }
+ tap { @includes.concat(sideloads.map(&:to_s)) }
end
# Adds an item to this collection
# @option item [ZendeskAPI::Data] the resource to add
# @raise [ArgumentError] if the resource doesn't belong in this collection
@@ -184,11 +184,11 @@
return @resources
elsif association && association.options.parent && association.options.parent.new_record?
return (@resources = [])
end
- @response = get_response(@query || self.path)
+ @response = get_response(@query || path)
handle_response(@response.body)
@resources
end
@@ -234,11 +234,11 @@
# Replaces the current (loaded or not) resources with the passed in collection
# @option collection [Array] The collection to replace this one with
# @raise [ArgumentError] if any resources passed in don't belong in this collection
def replace(collection)
- raise "this collection is for #{@resource_class}" if collection.any?{|r| !r.is_a?(@resource_class) }
+ raise "this collection is for #{@resource_class}" if collection.any? { |r| !r.is_a?(@resource_class) }
@resources = collection
end
# Find the next page. Does one of three things:
# * If there is already a page number in the options hash, it increases it and invalidates the cache, returning the new page number.
@@ -307,11 +307,11 @@
@resources.inspect
else
inspect = []
inspect << "options=#{@options.inspect}" if @options.any?
inspect << "path=#{path}"
- "#{Inflection.singular(@resource)} collection [#{inspect.join(",")}]"
+ "#{Inflection.singular(@resource)} collection [#{inspect.join(',')}]"
end
end
alias :to_str :to_s
@@ -396,10 +396,10 @@
## Fetch
def get_response(path)
@error = nil
@response = @client.connection.send(@verb || "get", path) do |req|
- opts = @options.delete_if {|_, v| v.nil?}
+ opts = @options.delete_if { |_, v| v.nil? }
req.params.merge!(:include => @includes.join(",")) if @includes.any?
if %w{put post}.include?(@verb.to_s)
req.body = opts