lib/rentjuicer/listings.rb in rentjuicer-0.8.0 vs lib/rentjuicer/listings.rb in rentjuicer-0.9.0

- old
+ new

@@ -10,20 +10,20 @@ def search(params = {}) limit = params[:limit] || 20 params[:order_by] ||= "rent" params[:order_direction] ||= "asc" - SearchResponse.new(self.client.process_get(resource, params), limit) + SearchResponse.new(self.client.process_get(resource, params), self.client, limit) end def featured(params = {}) params.merge!(:featured => 1) search(params) end def find_by_id(listing_id, params = {}) - response = SearchResponse.new(self.client.process_get(resource, params.merge(:rentjuice_id => listing_id))) + response = SearchResponse.new(self.client.process_get(resource, params.merge(:rentjuice_id => listing_id)), self.client) (response.success? && response.properties.size > 0) ? response.properties.first : nil end def find_all(params = {}) per_page = params[:limit] || 20 @@ -54,22 +54,23 @@ all_listings.flatten end class SearchResponse < Rentjuicer::Response - attr_accessor :limit + attr_accessor :limit, :client - def initialize(response, limit = 20) + def initialize(response, client, limit = 20) super(response) @limit = limit + @client = client end def properties @cached_properties ||= begin props = [] if self.success? && !self.body.listings.blank? self.body.listings.each do |listing| - props << Rentjuicer::Listing.new(listing) + props << Rentjuicer::Listing.new(listing, self.client) end end props end end