Sha256: 4ee230aa10bcd93ca073751b92eb720b6b96e42b3dd054908f8383a9d90b5503

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 Bytes

Contents

class Unit < MLS::Model
  self.inheritance_column = nil

  include MLS::Slugger
  include MLS::Avatar

  belongs_to :property
  belongs_to :floorplan, :class_name => 'Document'

  has_many :listings
  has_many :image_orderings, as: :subject, dependent: :destroy
  has_many :photos, through: :image_orderings, source: :image
  # has_many :photos, -> { order(:order => :asc) }, :as => :subject, :inverse_of => :subject

  has_and_belongs_to_many :uses

  def tags
    read_attribute(:tags) || []
  end

  def name
    name = ""
    case self.type
    when 'unit'
      name += "Unit"
      name += " #{self.number}" if self.number
      name += " (Floor #{self.floor})" if self.floor
    when 'floor'
      name += "Floor"
      name += " #{self.floor}" if self.floor
      name += " (Unit #{self.number})" if self.number
    when 'building'
      "Entire Building"
    end
    name
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mls-1.4.3 lib/mls/unit.rb