Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array::PG::TextEncoder::Array
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array::PG::TextEncoder::Array
- Defined in:
- lib/arjdbc/postgresql/base/array_encoder.rb
Instance Method Summary collapse
- #encode(values) ⇒ Object
-
#initialize(name:, delimiter:) ⇒ Array
constructor
A new instance of Array.
Constructor Details
#initialize(name:, delimiter:) ⇒ Array
Returns a new instance of Array.
10 11 12 13 14 15 16 17 |
# File 'lib/arjdbc/postgresql/base/array_encoder.rb', line 10 def initialize(name:, delimiter:) @type = if name == 'string[]' 'text'.freeze else base_type = name.chomp('[]').to_sym ActiveRecord::Base.connection.native_database_types[base_type][:name] end end |
Instance Method Details
#encode(values) ⇒ Object
19 20 21 |
# File 'lib/arjdbc/postgresql/base/array_encoder.rb', line 19 def encode(values) ActiveRecord::Base.connection.jdbc_connection.create_array_of(@type, values.to_java).to_s end |