lib/mls/models/listing.rb in mls-0.2.41 vs lib/mls/models/listing.rb in mls-0.2.42
- old
+ new
@@ -65,10 +65,14 @@
property :flyer_id, Fixnum, :serialize => :if_present
property :floorplan_id, Fixnum, :serialize => :if_present
property :avatar_digest, String, :serialize => false
+
+ # Counter Caches
+ property :photos_count Fixnum, :serialize => :false
+
attr_accessor :address, :agents, :account, :photos, :flyer, :floorplan, :videos
attr_writer :amenities
def avatar(size='150x100#', protocol='http')
if avatar_digest
@@ -212,10 +216,15 @@
def amenities
MLS.listing_amenities
end
+ def similar
+ response = MLS.get("/listings/#{self.id}/similar") # TODO: Number of listings?
+ MLS::Listing::Parser.parse_collection(response.body)
+ end
+
class << self
def find(id)
response = MLS.get("/listings/#{id}")
MLS::Listing::Parser.parse(response.body)
@@ -243,12 +252,10 @@
class MLS::Listing::Parser < MLS::Parser
def photos=(photos)
- @object.photos = photos.map do |p|
- MLS::Photo.new(:digest => p[:digest], :id => p[:id].to_i)
- end
+ @object.photos = photos.map {|p| MLS::Photo::Parser.build(p)}
end
def videos=(videos)
@object.videos = videos.map do |video|
MLS::Video::Parser.build(video)