Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array

Inherits:
Type::Value
  • Object
show all
Includes:
Type::Mutable
Defined in:
lib/active_record/connection_adapters/postgresql/oid/array.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from Type::Value

#limit, #precision, #scale

Instance Method Summary collapse

Methods included from Type::Mutable

#changed_in_place?

Methods inherited from Type::Value

#==, #binary?, #changed?, #changed_in_place?, #hash, #klass, #number?, #text?, #type, #type_cast_for_schema

Constructor Details

#initialize(subtype, delimiter = ',') ⇒ Array

Returns a new instance of Array.



23
24
25
26
# File 'lib/active_record/connection_adapters/postgresql/oid/array.rb', line 23

def initialize(subtype, delimiter = ',')
  @subtype = subtype
  @delimiter = delimiter
end

Instance Attribute Details

#delimiterObject (readonly)

Returns the value of attribute delimiter.



20
21
22
# File 'lib/active_record/connection_adapters/postgresql/oid/array.rb', line 20

def delimiter
  @delimiter
end

#subtypeObject (readonly)

Returns the value of attribute subtype.



20
21
22
# File 'lib/active_record/connection_adapters/postgresql/oid/array.rb', line 20

def subtype
  @subtype
end

Instance Method Details

#type_cast_for_database(value) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/active_record/connection_adapters/postgresql/oid/array.rb', line 43

def type_cast_for_database(value)
  if value.is_a?(::Array)
    cast_value_for_database(value)
  else
    super
  end
end

#type_cast_from_database(value) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/active_record/connection_adapters/postgresql/oid/array.rb', line 28

def type_cast_from_database(value)
  if value.is_a?(::String)
    type_cast_array(parse_pg_array(value), :type_cast_from_database)
  else
    super
  end
end

#type_cast_from_user(value) ⇒ Object



36
37
38
39
40
41
# File 'lib/active_record/connection_adapters/postgresql/oid/array.rb', line 36

def type_cast_from_user(value)
  if value.is_a?(::String)
    value = parse_pg_array(value)
  end
  type_cast_array(value, :type_cast_from_user)
end