Class: Ronin::SQL::StatementList

Inherits:
Object
  • Object
show all
Includes:
Emittable, Fields, Functions, Statements
Defined in:
lib/ronin/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, #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:



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

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::SQL::Fields

Instance Attribute Details

#statementsObject (readonly)

The list of statements



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

def statements
  @statements
end

Instance Method Details

#<<(statement) ⇒ self

Appends a statement.

Parameters:

  • statement (Statement)

    The SQL statement.

Returns:

  • (self)


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

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.



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

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

  self << new_statement
  return new_statement
end