Module: Archon::FactoryMethods
- Defined in:
- lib/archon/factory_methods.rb
Instance Method Summary collapse
- #sql_as(left, right) ⇒ Object
-
#sql_cast_as(new_type, castable) ⇒ Object
Returns a node that represents a ‘CAST( AS [new_type])` sql fragment.
- #sql_coalesce(*coalescees) ⇒ Object
-
#sql_insert_into_select(insertion_table, selection, options = {}) ⇒ Object
Returns a Insert Manager primed to insert the given ‘select-ish’ into the given ‘table-ish’.
- #sql_literal(literable) ⇒ Object
- #sql_populated_recordset(base, rows = []) ⇒ Object
- #sql_quoted(quotable) ⇒ Object
- #sql_table(name) ⇒ Object
- #sql_values(expressions) ⇒ Object
Instance Method Details
#sql_as(left, right) ⇒ Object
38 39 40 |
# File 'lib/archon/factory_methods.rb', line 38 def sql_as(left, right) Arel::Nodes::As.new left, right end |
#sql_cast_as(new_type, castable) ⇒ Object
Returns a node that represents a ‘CAST( AS [new_type])` sql fragment
16 17 18 19 |
# File 'lib/archon/factory_methods.rb', line 16 def sql_cast_as(new_type, castable) casting = Arel::Nodes::As.new castable, Arel::Nodes::SqlLiteral.new(new_type.to_s.upcase) Arel::Nodes::NamedFunction.new 'CAST', [casting] end |
#sql_coalesce(*coalescees) ⇒ Object
3 4 5 |
# File 'lib/archon/factory_methods.rb', line 3 def sql_coalesce(*coalescees) return Nodes::Coalesce.new(*coalescees) end |
#sql_insert_into_select(insertion_table, selection, options = {}) ⇒ Object
Returns a Insert Manager primed to insert the given ‘select-ish’ into the given ‘table-ish’
22 23 24 |
# File 'lib/archon/factory_methods.rb', line 22 def sql_insert_into_select(insertion_table, selection, = {}) InsertIntoSelect.new insertion_table, selection, end |
#sql_literal(literable) ⇒ Object
34 35 36 |
# File 'lib/archon/factory_methods.rb', line 34 def sql_literal(literable) Arel::Nodes::SqlLiteral.new literable end |
#sql_populated_recordset(base, rows = []) ⇒ Object
7 8 9 |
# File 'lib/archon/factory_methods.rb', line 7 def sql_populated_recordset(base, rows = []) return Nodes::PopulatedRecordset.new base, rows end |
#sql_quoted(quotable) ⇒ Object
30 31 32 |
# File 'lib/archon/factory_methods.rb', line 30 def sql_quoted(quotable) Arel::Nodes::Quoted.new quotable end |
#sql_table(name) ⇒ Object
26 27 28 |
# File 'lib/archon/factory_methods.rb', line 26 def sql_table(name) Arel::Table.new name end |