aboutsummaryrefslogtreecommitdiff
path: root/app/models/resource.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/resource.rb')
-rw-r--r--app/models/resource.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/models/resource.rb b/app/models/resource.rb
index 906933d..7d87e1a 100644
--- a/app/models/resource.rb
+++ b/app/models/resource.rb
@@ -8,8 +8,7 @@ class Resource < ApplicationRecord
has_many :classifications
has_many :sections, through: :classifications
- serialize :feature, HashSerializer
- store_accessor :feature, :name, :summary, :description, :email, :source, :address, :postal_code, :city, :phone_number, :website
+ store_accessor :feature, :geometry, :properties
validates_associated :agent
@@ -53,4 +52,16 @@ class Resource < ApplicationRecord
def latitude=(value)
feature['geometry']['coordinates'][1] = value
end
+
+ # Properties
+
+ [:name, :summary, :description, :email, :source, :address, :postal_code, :city, :phone_number, :website].each do |prop|
+ # Define a reader
+ define_method prop do
+ properties[prop.to_s]
+ end
+ define_method :"#{prop}=" do |v|
+ feature['properties'][prop.to_s] = v
+ end
+ end
end