Module: DbMod::Statements::Configuration::As
- Defined in:
- lib/db_mod/statements/configuration/as.rb,
lib/db_mod/statements/configuration/as/csv.rb,
lib/db_mod/statements/configuration/as/json.rb
Overview
Contains coercers and other functions that allow module instance methods returning an SQL result set to be extended with additional result coercion and formatting. The normal way to access this functionality is via MethodConfiguration#as, which is available when defining a statement method or prepared method:
def_statement(:a, 'SELECT a, b, c FROM foo').as(:csv)
def_prepared(:b, 'SELECT d, e, f FROM bar').as(:csv)
Defined Under Namespace
Constant Summary collapse
- COERCERS =
List of available result coercion methods. Only keys defined here are allowed as arguments to ConfigurableMethod#as.
{ csv: As::Csv, json: As::Json }
Class Method Summary collapse
-
.extend(definition, config) ⇒ Object
Extend the given method definition with additional result coercion.
Class Method Details
.extend(definition, config) ⇒ Object
Extend the given method definition with additional result coercion.
31 32 33 34 35 36 |
# File 'lib/db_mod/statements/configuration/as.rb', line 31 def self.extend(definition, config) type = config[:as] return definition if type.nil? Configuration.attach_result_processor definition, COERCERS[type] end |