Module: Rentlinx::Photoable

Included in:
Property, Unit
Defined in:
lib/rentlinx/modules/photoable.rb

Overview

A module that encapsulates all photo related logic for Property and Unit objects. All of these methods can be called on Properties and Units.

TODO: Refactor into BaseAble class along with Linkable and Amenityable

Instance Method Summary collapse

Instance Method Details

#add_photo(options) ⇒ Object



34
35
36
37
38
39
# File 'lib/rentlinx/modules/photoable.rb', line 34

def add_photo(options)
  options[:propertyID] = propertyID
  options[:unitID] = unitID if defined? unitID
  @photos ||= []
  @photos << photo_class.new(options)
end

#photosObject



22
23
24
# File 'lib/rentlinx/modules/photoable.rb', line 22

def photos
  @photos ||= get_photos_for_property_id(propertyID)
end

#photos=(photo_list) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rentlinx/modules/photoable.rb', line 26

def photos=(photo_list)
  @photos = photo_list.map do |photo|
    photo.propertyID = propertyID
    photo.unitID = unitID if defined? unitID
    photo
  end
end

#post_photosObject



12
13
14
15
16
17
18
19
20
# File 'lib/rentlinx/modules/photoable.rb', line 12

def post_photos
  return if @photos.nil?

  if @photos.empty?
    Rentlinx.client.unpost_photos_for(self)
  else
    Rentlinx.client.post_photos(@photos)
  end
end

#post_with_photosObject



7
8
9
10
# File 'lib/rentlinx/modules/photoable.rb', line 7

def post_with_photos
  post
  post_photos
end