Class: PgExecArrayParams::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_exec_array_params/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query, args = []) ⇒ Query

Returns a new instance of Query.



9
10
11
12
# File 'lib/pg_exec_array_params/query.rb', line 9

def initialize(query, args = [])
  @query = query
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



7
8
9
# File 'lib/pg_exec_array_params/query.rb', line 7

def args
  @args
end

#queryObject (readonly)

Returns the value of attribute query.



7
8
9
# File 'lib/pg_exec_array_params/query.rb', line 7

def query
  @query
end

Instance Method Details

#bindsObject



22
23
24
# File 'lib/pg_exec_array_params/query.rb', line 22

def binds
  should_rebuild? ? (@binds ||= args.flatten(1)) : args
end

#columnsObject



26
27
28
# File 'lib/pg_exec_array_params/query.rb', line 26

def columns
  @columns || (rebuild_query! && @columns)
end

#exec_params(conn, *args) ⇒ Object



14
15
16
# File 'lib/pg_exec_array_params/query.rb', line 14

def exec_params(conn, *args)
  conn.exec_params(sql, binds, *args)
end

#sqlObject



18
19
20
# File 'lib/pg_exec_array_params/query.rb', line 18

def sql
  should_rebuild? ? (@sql || (rebuild_query! && @sql)) : query
end