Sha256: cd3e04c868838766115da7b3290fb1d978c4db3e68a8a90025d5db1813984f5f

Contents?: true

Size: 431 Bytes

Versions: 6

Compression:

Stored size: 431 Bytes

Contents

#
# Hood/Neighborhood
#
class Hood
  include Mongoid::Document
  include Geopolitocracy

  field :rank,  type: Integer

  belongs_to :city

  validates :city, presence: true
  validates :name, uniqueness: { scope: :city_id }

  def phone
    self[:phone] || city.phone
  end

  def postal
    self[:postal] || city.postal
  end

  def as_json(_opts = {})
    {
      id: id.to_s,
      name: name,
      city: city
    }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geopolitical-1.0.2 app/models/hood.rb
geopolitical-1.0.0 app/models/hood.rb
geopolitical-0.9.9 app/models/hood.rb
geopolitical-0.9.7 app/models/hood.rb
geopolitical-0.9.5 app/models/hood.rb
geopolitical-0.9.3 app/models/hood.rb