Module: TheGeomGeoJSON::ActiveRecord

Defined in:
lib/the_geom_geojson/active_record.rb

Instance Method Summary collapse

Instance Method Details

#the_geomObject



60
61
62
63
64
65
66
# File 'lib/the_geom_geojson/active_record.rb', line 60

def the_geom
  if @the_geom_geojson_dirty
    raise TheGeomGeoJSON::Dirty, "the_geom can't be accessed on #{self.class.name} id #{id.inspect} until it has been saved"
  else
    read_attribute :the_geom
  end
end

#the_geom_geojsonObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/the_geom_geojson/active_record.rb', line 48

def the_geom_geojson
  if @the_geom_geojson_dirty
    @the_geom_geojson_change
  elsif preselected = read_attribute(:the_geom_geojson)
    preselected
  elsif the_geom
    self.class.connection_pool.with_connection do |c|
      c.select_value "SELECT ST_AsGeoJSON(the_geom) FROM #{self.class.quoted_table_name} WHERE #{self.class.quoted_primary_key} = #{c.quote(id)} LIMIT 1"
    end
  end
end

#the_geom_geojson=(v) ⇒ Object



42
43
44
45
# File 'lib/the_geom_geojson/active_record.rb', line 42

def the_geom_geojson=(v)
  @the_geom_geojson_dirty = true
  @the_geom_geojson_change = v
end

#the_geom_webmercatorObject



68
69
70
71
72
73
74
# File 'lib/the_geom_geojson/active_record.rb', line 68

def the_geom_webmercator
  if @the_geom_geojson_dirty
    raise TheGeomGeoJSON::Dirty, "the_geom_webmercator can't be accessed on #{self.class.name} id #{id.inspect} until it has been saved"
  else
    read_attribute :the_geom_webmercator
  end
end