Permalink
Browse files

Changing how flyers are dealt with

  • Loading branch information...
1 parent 289353f commit 85b33942e74d2e59139a350ccffc966e5c76531c @malomalo malomalo committed Dec 27, 2012
Showing with 12 additions and 9 deletions.
  1. +11 −7 lib/mls/models/flyer.rb
  2. +1 −2 lib/mls/models/listing.rb
View
@@ -3,15 +3,19 @@
class MLS::Flyer < MLS::Resource
property :id, Fixnum
- property :subject_id, Fixnum
- property :subject_type, String
- property :created_at, DateTime
- property :updated_at, DateTime
- property :file_content_type, String
+ property :digest, String
+ property :avatar_digest, String
property :file_name, String
property :file_size, Fixnum
- property :url, String
-
+
+ def url(protocol='http')
+ "#{protocol}://#{MLS.asset_host}/flyers/#{digest}/#{file_name}"
+ end
+
+ def avatar(size='150x100', protocol='http')
+ "#{protocol}://#{MLS.asset_host}/photos/#{size}/#{avatar_digest}.jpg"
+ end
+
def self.create(attrs)
attrs[:file].rewind
url = MLS.url.dup
@@ -243,8 +243,7 @@ def floor_plan=(floor_plan)
end
def flyer=(flyer)
- @object.flyer = MLS::PDF.new(:digest => flyer[:digest], :id => flyer[:id].to_i,
- :file_url => flyer[:file_url], :type => :flyer)
+ @object.flyer = MLS::Flyer::Parser.build(flyer)
end
def address=(address)

0 comments on commit 85b3394

Please sign in to comment.