Module: DbMod::Statements::Configuration::Single::Column
- Defined in:
- lib/db_mod/statements/configuration/single/column.rb
Overview
Wrapper for a statement or prepared method that returns an array of the values from the first value of every row returned by the SQL statement.
def_statement(:a, 'SELECT a FROM b').single(:column)
def do_stuff
a # => ['a', 'b', 'c']
end
Class Method Summary collapse
-
.call(results) ⇒ Array<String>
Enables this module to be passed to DbMod::Statements::Configuration.process_method_results as the
wrapper
function, where it will return an array of the first value from every row in the result set.
Class Method Details
.call(results) ⇒ Array<String>
Enables this module to be passed to DbMod::Statements::Configuration.process_method_results as the wrapper
function, where it will return an array of the first value from every row in the result set.
22 23 24 |
# File 'lib/db_mod/statements/configuration/single/column.rb', line 22 def self.call(results) results.map { |row| row[row.keys.first] } end |