aboutsummaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-10-06 19:29:04 +0200
committerhellekin <hellekin@cepheide.org>2020-10-06 19:29:04 +0200
commit1564af069472e32ed322bf9acedc9c487bce1a15 (patch)
treed3bd0061dd08b4d236b02f1cf978466873ecc83d /app/models
parentb5052d4beeb7fd0bc14db21336588bb0483f7d09 (diff)
downloadincommon-map-1564af069472e32ed322bf9acedc9c487bce1a15.tar.gz
First pass at listing Resources
This implements resource listing and pagination. See /resources
Diffstat (limited to 'app/models')
-rw-r--r--app/models/resource.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/resource.rb b/app/models/resource.rb
index ba3dd1f..e67d164 100644
--- a/app/models/resource.rb
+++ b/app/models/resource.rb
@@ -3,4 +3,23 @@ class Resource < ApplicationRecord
include UUIDParameter
belongs_to :agent
+
+ # Figure out the requested property name
+ def method_missing(name, *args, &block)
+ Rails.logger.info("method_missing: #{name} // #{feature['properties'][name.to_s]}")
+ if feature['properties'].key?(name.to_s)
+ feature['properties'][name.to_s]
+ else
+ case name.to_s
+ when 'lon', 'longitude'
+ feature['geometry']['coordinates'].first
+ when 'lat', 'latitude'
+ feature['geometry']['coordinates'].last
+ when 'geo_type'
+ feature['geometry']['type']
+ else
+ super
+ end
+ end
+ end
end