Method: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array#cast

Defined in:
lib/active_record/connection_adapters/postgresql/oid/array.rb

#cast(value) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_record/connection_adapters/postgresql/oid/array.rb', line 34

def cast(value)
  if value.is_a?(::String)
    value = begin
      @pg_decoder.decode(value)
    rescue TypeError
      # malformed array string is treated as [], will raise in PG 2.0 gem
      # this keeps a consistent implementation
      []
    end
  end
  type_cast_array(value, :cast)
end