Module: PostgresExt::Postgis::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::Quoting

Defined in:
lib/postgres_ext/postgis/active_record/connection_adapters/postgresql_adapter.rb

Instance Method Summary collapse

Instance Method Details

#quote(value, column = nil) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/postgres_ext/postgis/active_record/connection_adapters/postgresql_adapter.rb', line 59

def quote(value, column = nil)
  if column && column.type == :geometry
    ActiveRecord::ConnectionAdapters::PostgreSQLColumn.geometry_to_string(value)
  else
    super
  end
end

#type_cast(value, column, array_member = false) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/postgres_ext/postgis/active_record/connection_adapters/postgresql_adapter.rb', line 67

def type_cast(value, column, array_member = false)
  return super unless column

  case value
  when RGeo::Feature::Instance
    return super unless /geometry/ =~ column.sql_type
    ActiveRecord::ConnectionAdapters::PostgreSQLColumn.geometry_to_string(value)
  else
    super
  end
end