class PgExecArrayParams::Column

Attributes

as_name[R]
column_name[R]
table[R]

Public Class Methods

from_res_target(res_target) click to toggle source
# 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
new(table:, column_name:, as_name:) click to toggle source
# 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

Public Instance Methods

name() click to toggle source
# File lib/pg_exec_array_params/column.rb, line 13
def name
  @as_name || @column_name
end