Sha256: 46d984c83978b47a6f30a40194937d31e0016e8813da256c090124002d852f6f
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
class Address include Mongoid::Document # include Mongoid::Symbolize include Mongoid::Timestamps include Mongoid::Geospatial field :zip, type: String field :name, type: String field :title, type: String field :number, type: String field :extra, type: String field :info, type: String field :geom, type: Point field :hood_name, type: String field :city_name, type: String field :region_name, type: String field :nation_name, type: String embedded_in :addressable, polymorphic: true belongs_to :nation belongs_to :region belongs_to :city belongs_to :hood validates :name, presence: true def print_location "#{hood_name} #{city_name} - #{region_name} " end def print_full_location print_location + nation_name end def geom g = super unless g self.geom = '0,0' return super end g end def geom=(data) self[:geom] = data.split(',') end def form_geom "#{geom.try(:x)},#{geom.try(:y)}" end def form_geom=(data) self.geom = data end def to_s "#{name} #{number}" + print_location end #index tie_id: 1, created_at: -1 # symbolize :kind, :in => [:street, :avenue, :road], default: :street end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
geopolitical-0.8.1 | app/models/address.rb |
geopolitical-0.8.0 | app/models/address.rb |