Class: PgExecArrayParams::Column
- Inherits:
-
Object
- Object
- PgExecArrayParams::Column
- Defined in:
- lib/pg_exec_array_params/column.rb
Instance Attribute Summary collapse
-
#as_name ⇒ Object
readonly
Returns the value of attribute as_name.
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(table:, column_name:, as_name:) ⇒ Column
constructor
A new instance of Column.
- #name ⇒ Object
Constructor Details
#initialize(table:, column_name:, as_name:) ⇒ Column
Returns a new instance of Column.
7 8 9 10 11 |
# File 'lib/pg_exec_array_params/column.rb', line 7 def initialize(table:, column_name:, as_name:) @table = table @column_name = column_name @as_name = as_name end |
Instance Attribute Details
#as_name ⇒ Object (readonly)
Returns the value of attribute as_name.
5 6 7 |
# File 'lib/pg_exec_array_params/column.rb', line 5 def as_name @as_name end |
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
5 6 7 |
# File 'lib/pg_exec_array_params/column.rb', line 5 def column_name @column_name end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
5 6 7 |
# File 'lib/pg_exec_array_params/column.rb', line 5 def table @table end |
Class Method Details
.from_res_target(res_target) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pg_exec_array_params/column.rb', line 17 def self.from_res_target(res_target) return unless (column_ref = res_target.fetch('val', {})['ColumnRef']) idents = column_ref['fields'].map { |field| field.fetch('String', {})['str'] } if idents.size <= 1 column_name = idents.first else table, column_name, = idents end return unless column_name new(table: table, column_name: column_name, as_name: res_target['name']) end |
Instance Method Details
#name ⇒ Object
13 14 15 |
# File 'lib/pg_exec_array_params/column.rb', line 13 def name @as_name || @column_name end |