app/models/unidom/geo/china/region.rb in unidom-geo-china-0.3.2 vs app/models/unidom/geo/china/region.rb in unidom-geo-china-0.4
- old
+ new
@@ -25,20 +25,19 @@
self.table_name = 'unidom_china_regions'
include Unidom::Common::Concerns::ModelExtension
include Unidom::Geo::Concerns::AsRegion
+ include Unidom::Geo::China::Concerns::AsInferiorRegion
+ include Unidom::Geo::China::Concerns::AsSuperiorRegion
validates :numeric_code, numericality: { integer_only: true }
validates :alphabetic_code, allow_blank: true, length: { minimum: 2 }
validates :name, presence: true, length: { maximum: self.columns_hash['name'].limit }
belongs_to :scheme, polymorphic: true
- #has_many :locations, class_name: 'Unidom::Geo::Location', as: :region
- #has_many :locatings, through: :locations, source: :locatings
-
has_many :towns, class_name: 'Unidom::Geo::China::Town'
scope :scheme_is, ->(scheme) { scheme.present? ? where(scheme: scheme) : scheme_id_is.scheme_type_is }
scope :scheme_id_is, ->(scheme_id = Unidom::Common::NULL_UUID) { where scheme_id: scheme_id }
scope :scheme_type_is, ->(scheme_type = '' ) { where scheme_type: scheme_type }
@@ -78,10 +77,11 @@
def mducg?
under_mducg? && numeric_code_middle_empty? && numeric_code_suffix_empty?
end
+=begin
def super_regions
numeric_code_suffix_empty? ? (numeric_code_middle_empty? ? self.class.none : self.class.numeric_coded_as("#{numeric_code_prefix}0000")) : self.class.numeric_coded_as("#{numeric_code_prefix}#{numeric_code_middle}00")
end
def sub_regions
@@ -92,9 +92,10 @@
regions
else
self.class.none
end
end
+=end
def full_name(separator = ' ')
final_name = self.name
current_region = self
count = 0