Class: YouGotListed::Complex
- Inherits:
-
Object
- Object
- YouGotListed::Complex
- Defined in:
- lib/you_got_listed/complex.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #find_address(address_id) ⇒ Object
-
#initialize(listing, client) ⇒ Complex
constructor
A new instance of Complex.
- #pictures ⇒ Object
- #properties ⇒ Object
Constructor Details
#initialize(listing, client) ⇒ Complex
Returns a new instance of Complex.
6 7 8 9 10 11 12 |
# File 'lib/you_got_listed/complex.rb', line 6 def initialize(listing, client) listing.each do |key, value| self.instance_variable_set("@#{key}", value) self.class.send(:attr_reader, key) end self.client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/you_got_listed/complex.rb', line 4 def client @client end |
Instance Method Details
#find_address(address_id) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/you_got_listed/complex.rb', line 36 def find_address(address_id) if addresses.address.is_a?(Array) if address_id.blank? addresses.address.first else addresses.address.find{|address| address.id == address_id} end else addresses.address end end |
#pictures ⇒ Object
32 33 34 |
# File 'lib/you_got_listed/complex.rb', line 32 def pictures self.photos.photo unless self.photos.blank? || self.photos.photo.blank? end |
#properties ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/you_got_listed/complex.rb', line 14 def properties @cached_properties ||= begin props = [] if defined?(self.listings) && !self.listings.blank? if self.listings.listing.is_a?(Array) self.listings.listing.each do |listing| listing = listing.merge(find_address(listing.address_id)) props << YouGotListed::Listing.new(listing, self.client) end else listing = self.listings.listing.merge(find_address(self.listings.listing.address_id)) props << YouGotListed::Listing.new(listing, self.client) end end props end end |