diff options
Diffstat (limited to 'app/models/resource.rb')
-rw-r--r-- | app/models/resource.rb | 19 |
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 |