Class: ROM::SQL::Postgres::Types::ArrayTypes Private
- Inherits:
-
Object
- Object
- ROM::SQL::Postgres::Types::ArrayTypes
- Defined in:
- lib/rom/sql/extensions/postgres/types/array_types.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #base_read_type ⇒ Object readonly private
- #base_write_type ⇒ Object readonly private
- #constructor ⇒ Object readonly private
- #elements ⇒ Object readonly private
Instance Method Summary collapse
- #[](db_type, member_type = nil) ⇒ Object private
-
#initialize(base_write_type, base_read_type) ⇒ ArrayTypes
constructor
private
A new instance of ArrayTypes.
Constructor Details
#initialize(base_write_type, base_read_type) ⇒ ArrayTypes
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ArrayTypes.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rom/sql/extensions/postgres/types/array_types.rb', line 19 def initialize(base_write_type, base_read_type) @elements = {} @base_write_type = base_write_type @base_read_type = base_read_type @constructor = proc { |db_type, member| if member -> arr { Sequel.pg_array(arr.map { |v| member[v] }, db_type) } else -> arr { Sequel.pg_array(arr, db_type) } end } end |
Instance Attribute Details
#base_read_type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/rom/sql/extensions/postgres/types/array_types.rb', line 17 def base_read_type @base_read_type end |
#base_write_type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/rom/sql/extensions/postgres/types/array_types.rb', line 15 def base_write_type @base_write_type end |
#constructor ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/rom/sql/extensions/postgres/types/array_types.rb', line 13 def constructor @constructor end |
#elements ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/rom/sql/extensions/postgres/types/array_types.rb', line 11 def elements @elements end |
Instance Method Details
#[](db_type, member_type = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rom/sql/extensions/postgres/types/array_types.rb', line 32 def [](db_type, member_type = nil) elements.fetch(db_type) do name = "#{db_type}[]" write_type = build_write_type(db_type, member_type) read_type = build_read_type(db_type, member_type) array_type = Types.Type(name, write_type).(type: db_type, read: read_type) register_extension(array_type) elements[db_type] = array_type end end |