Sha256: 639a5e46ff556b7f040285d980dbc99f00a49c321f95f13e9feb0e148fbd260a

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

class InscriptioCursualis::Address < InscriptioCursualis::Model
  self.abstract_class = true

  has_paper_trail

  belongs_to :neighborhood, class_name: '::Neighborhood'
  belongs_to :street, class_name: '::Street'
  belongs_to :land_subdivision, class_name: '::LandSubdivision'
  belongs_to :condominium, class_name: '::Condominium'
  belongs_to :addressable, polymorphic: true

  validates :neighborhood, :street, :zip_code, presence: true
  validates :zip_code, mask: '99999-999', allow_blank: true
  validates :number, numericality: true, allow_blank: true

  delegate :street_type, to: :street, allow_nil: true
  delegate :city, :district, to: :neighborhood, allow_nil: true
  delegate :state, to: :city, allow_nil: true
  delegate :country, to: :state, allow_nil: true

  def to_s
    "#{street}, #{number} - #{neighborhood}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unico-training-7.8.0 app/models/inscriptio_cursualis/address.rb