Sha256: 739c8fe6a620895f8f7b6bf5cb17231f47e19c1d0d9eaa7583ffd207b7a5e85d
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
module YouGotListed class Complex attr_accessor :client 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 def properties @cached_properties ||= begin props = [] unless 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(listing.address_id)) props << YouGotListed::Listing.new(listing, self.client) end end props end end def pictures self.photos.photo unless self.photos.blank? || self.photos.photo.blank? end def find_address(address_id) if addresses.address.is_a?(Array) addresses.address.find{|address| address.id == address_id} else addresses.address end end end end
Version data entries
6 entries across 6 versions & 1 rubygems