Module: Rentlinx::Linkable
Overview
A module that encapsulates all link 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 Amenityable and Photoable
Instance Method Summary collapse
- #add_link(options) ⇒ Object
-
#links ⇒ Object
Loads and caches the list of amenities from Rentlinx.
- #links=(link_list) ⇒ Object
-
#post_links ⇒ Object
Posts the links for an object.
-
#post_with_links ⇒ Object
Posts the object with associated links.
Instance Method Details
#add_link(options) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/rentlinx/modules/linkable.rb', line 47 def add_link() [:propertyID] = propertyID [:unitID] = unitID if defined? unitID @links ||= [] @links << link_class.new() end |
#links ⇒ Object
Loads and caches the list of amenities from Rentlinx.
30 31 32 33 34 35 36 37 |
# File 'lib/rentlinx/modules/linkable.rb', line 30 def links @links ||= if defined? unitID Rentlinx.client.get_links_for_unit(self) else Rentlinx.client.get_links_for_property_id(propertyID) end end |
#links=(link_list) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/rentlinx/modules/linkable.rb', line 39 def links=(link_list) @links = link_list.map do |link| link.propertyID = propertyID link.unitID = unitID if defined? unitID link end end |
#post_links ⇒ Object
Posts the links for an object
17 18 19 20 21 22 23 24 25 |
# File 'lib/rentlinx/modules/linkable.rb', line 17 def post_links return if @links.nil? if @links.empty? Rentlinx.client.unpost_links_for(self) else Rentlinx.client.post_links(@links) end end |
#post_with_links ⇒ Object
Posts the object with associated links
TODO: Discuss whether or not these kinds of methods are needed, or whether we should have post do everything every time.
11 12 13 14 |
# File 'lib/rentlinx/modules/linkable.rb', line 11 def post_with_links post post_links end |