app/models/popolo/area.rb in popolo-0.0.2 vs app/models/popolo/area.rb in popolo-0.0.3
- old
+ new
@@ -1,25 +1,33 @@
module Popolo
- # A bounded area, like an administrative boundary.
- #
- # @note There is an upper limit to the number of administrative levels;
- # however, there is little agreement as to what those levels are. Therefore,
- # instead of having a different model for each administrative level – which
- # would have advantages – we use a flexible tree structure.
+ # A geographic area whose geometry may change over time.
class Area
include Mongoid::Document
+ include Mongoid::Timestamps
include Mongoid::Tree
- include Popolo::Sluggable
- index({slug: 1, parent_id: 1}, unique: true)
+ store_in Popolo.storage_options_per_class.fetch(:Area, Popolo.storage_options)
- # Memberships related to the area, e.g. officials.
+ # The geographic area to which the membership is related.
has_many :memberships, class_name: 'Popolo::Membership'
- # Organizations related to the area, e.g. governments.
+ # The geographic area to which the organization is related.
has_many :organizations, class_name: 'Popolo::Organization'
- # Posts related to the area, e.g. officials.
+ # The geographic area to which the post is related.
has_many :posts, class_name: 'Popolo::Post'
- # The area's category.
+ # URLs to documents from which the area is derived.
+ embeds_many :sources, as: :linkable, class_name: 'Popolo::Link'
+
+ # A primary name.
+ field :name, type: String
+ # An issued identifier.
+ field :identifier, type: String
+ # An area category, e.g. city.
field :classification, type: String
+ # A geometry.
+ field :geometry, type: String
+
+ def to_s
+ name
+ end
end
end