blob: cd43bf9e231f7153d8773a1ff10bc8cf215a888d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
class Resource < ApplicationRecord
# Universally Unique Identifier :uuid
include UUIDParameter
belongs_to :agent
has_and_belongs_to_many :sections
# 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
|