Module: Ronin::SQL::Emittable

Included in:
BinaryExpr, Clause, Field, Function, InjectionExpr, Literal, Statement, StatementList, UnaryExpr
Defined in:
lib/ronin/sql/emittable.rb

Overview

Allows an object to be converted to raw SQL.

Instance Method Summary collapse

Instance Method Details

#emitter(options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new emitter.

Parameters:



41
42
43
# File 'lib/ronin/sql/emittable.rb', line 41

def emitter(options={})
  Emitter.new(options)
end

#inspectString

Inspects the object.

Returns:

  • (String)

    The inspected object.



83
84
85
# File 'lib/ronin/sql/emittable.rb', line 83

def inspect
  "#<#{self.class}: #{to_sql}>"
end

#to_sObject

See Also:



73
74
75
# File 'lib/ronin/sql/emittable.rb', line 73

def to_s
  to_sql
end

#to_sql(options = {}) ⇒ String

The default to_sql method.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options for #emitter.

Options Hash (options):

  • :case (:lower, :upper, :random, nil)

    Case for keywords.

  • :space (String) — default: ' '

    String to use for white-space.

  • :quotes (:single, :double) — default: :single

    Type of quotes to use for Strings.

Returns:

Raises:

  • (ArgumentError)

    Could not emit an unknown SQL object.



66
67
68
# File 'lib/ronin/sql/emittable.rb', line 66

def to_sql(options={})
  emitter(options).emit(self)
end