Class: ActiveRecord::ConnectionAdapters::PostgreSQLColumn
- Inherits:
-
Column
- Object
- Column
- ActiveRecord::ConnectionAdapters::PostgreSQLColumn
- Defined in:
- lib/activerecord-postgres-array/activerecord.rb
Instance Method Summary collapse
-
#simplified_type_with_array(field_type) ⇒ Object
Adds the array type for the column.
-
#type_cast_code_with_array(var_name) ⇒ Object
Does the type casting from array columns using String#from_postgres_array or Array#from_postgres_array.
Instance Method Details
#simplified_type_with_array(field_type) ⇒ Object
Adds the array type for the column.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/activerecord-postgres-array/activerecord.rb', line 84 def simplified_type_with_array(field_type) if field_type =~ /^numeric.+\[\]$/ :decimal_array elsif field_type =~ /character varying.*\[\]/ :string_array elsif field_type =~ /\[\]$/ field_type.gsub(/\[\]/, '_array').to_sym else simplified_type_without_array(field_type) end end |
#type_cast_code_with_array(var_name) ⇒ Object
Does the type casting from array columns using String#from_postgres_array or Array#from_postgres_array.
73 74 75 76 77 78 79 80 |
# File 'lib/activerecord-postgres-array/activerecord.rb', line 73 def type_cast_code_with_array(var_name) if type.to_s =~ /_array$/ base_type = type.to_s.gsub(/_array/, '') "#{var_name}.from_postgres_array(:#{base_type})" else type_cast_code_without_array(var_name) end end |