Class: Ronin::Code::SQL::StatementList

Inherits:
Object
  • Object
show all
Includes:
Emittable, Fields, Functions, Statements
Defined in:
lib/ronin/code/sql/statement_list.rb

Overview

Represents a list of SQL Statement.

Direct Known Subclasses

Injection

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Emittable

#emitter, #inspect, #to_s, #to_sql

Methods included from Statements

#delete, #drop_table, #insert, #select, #update

Methods included from Functions

#abs, #acos, #ascii, #asin, #atan, #atan2, #avg, #bin, #bit_and, #bit_count, #bit_length, #bit_or, #ceil, #ceiling, #char, #char_length, #character_length, #concat, #concat_ws, #conv, #cos, #cot, #count, #degrees, #elt, #exp, #export_set, #field, #find_in_set, #floor, #format, #glob, #greatest, #hex, #insert, #instr, #interval, #lcase, #least, #left, #length, #like, #load_file, #locate, #log, #log10, #lower, #lpad, #ltrim, #make_set, #max, #mid, #min, #mod, #oct, #octet_length, #ord, #pi, #position, #pow, #power, #quote, #radians, #rand, #random, #repeat, #replace, #reverse, #right, #round, #rpad, #rtrim, #sign, #sin, #sleep, #soundex, #space, #sqrt, #std, #stddev, #strcmp, #substring, #substring_index, #sum, #tan, #trim, #truncate, #ucase, #unhex, #upper

Methods included from Fields

#method_missing, #respond_to_missing?, #to_ary

Constructor Details

#initialize {|(statements)| ... } ⇒ StatementList

Initializes a new SQL statement list.

Yields:

  • ((statements))

    If a block is given, it will be evaluated within the statement list. If the block accepts an argument, the block will be called with the new statement list.

Yield Parameters:



59
60
61
62
63
64
65
66
67
68
# File 'lib/ronin/code/sql/statement_list.rb', line 59

def initialize(&block)
  @statements = []

  if block
    case block.arity
    when 0 then instance_eval(&block)
    else        block.call(self)
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ronin::Code::SQL::Fields

Instance Attribute Details

#statementsObject (readonly)

The list of statements



46
47
48
# File 'lib/ronin/code/sql/statement_list.rb', line 46

def statements
  @statements
end

Instance Method Details

#<<(statement) ⇒ self

Appends a statement.

Parameters:

  • statement (Statement)

    The SQL statement.

Returns:

  • (self)


78
79
80
81
# File 'lib/ronin/code/sql/statement_list.rb', line 78

def <<(statement)
  @statements << statement
  return self
end

#statement(keyword, argument = nil) {|(statement)| ... } ⇒ Statement

Appends an arbitrary statement.

Parameters:

  • keyword (Symbol)

    Name of the statement.

  • argument (Object) (defaults to: nil)

    Additional argument for the statement.

Yields:

  • ((statement))

    If a block is given, it will be called.

Yield Parameters:

  • statement (Statement)

    If the block accepts an argument, it will be passed the new statement. Otherwise the block will be evaluated within the statement.

Returns:

  • (Statement)

    The newly created statement.



102
103
104
105
106
107
# File 'lib/ronin/code/sql/statement_list.rb', line 102

def statement(keyword,argument=nil,&block)
  new_statement = super

  self << new_statement
  return new_statement
end