Sha256: f1e8b49d242394c42cc1c443164fa506e679f8ad1bbf73f62f7e89f8ae4f96bd
Contents?: true
Size: 1.82 KB
Versions: 13
Compression:
Stored size: 1.82 KB
Contents
module YouGotListed class Complexes < Resource def search(params = {}) params[:page_count] ||= 20 params[:page_index] ||= 1 params[:sort_name] ||= "Name" params[:sort_dir] ||= "asc" params[:detail_level] ||= 2 SearchResponse.new(self.client.perform_request(:get, '/complexes/search.php', params), self.client, params[:page_count]) end def find_by_id(complex_id) response = SearchResponse.new(self.client.perform_request(:get, '/complexes/search.php', {:complex_id => complex_id}), self.client, 20) (response.success? && response.property_complexes.size > 0) ? response.property_complexes.first : nil end class SearchResponse < YouGotListed::Response attr_accessor :limit, :client def initialize(response, client, limit = 20, raise_error = false) super(response, raise_error) self.limit = limit self.client = client end def property_complexes @cached_property_complexes ||= begin props = [] if self.success? && !self.ygl_response.complexes.blank? if self.ygl_response.complexes.complex.is_a?(Array) self.ygl_response.complexes.complex.each do |complex| props << YouGotListed::Complex.new(complex, self.client) end else props << YouGotListed::Complex.new(self.ygl_response.complexes.complex, self.client) end end props end end def paginator @paginator_cache ||= WillPaginate::Collection.create( (self.ygl_response.page_index ? self.ygl_response.page_index : 1), self.limit, (self.ygl_response.total ? self.ygl_response.total : properties.size)) do |pager| pager.replace property_complexes end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems