Class: Ronin::Code::SQL::Statement

Inherits:
Object
  • Object
show all
Includes:
Clauses, Emittable, Literals, Operators
Defined in:
lib/ronin/code/sql/statement.rb

Overview

Represents a SQL Statement.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Emittable

#emitter, #inspect, #to_s, #to_sql

Methods included from Clauses

#clause, #clauses, #default_values, #from, #full_join, #group_by, #having, #indexed_by, #inner_join, #into, #join, #left_join, #limit, #not_indexed, #offset, #on, #order_by, #right_join, #set, #top, #union, #union_all, #values, #where

Methods included from Operators

#!, #!=, #%, #&, #*, #+, #+@, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #and, #as, #glob, #in, #is, #is_not, #like, #match, #not, #or, #regexp, #|, #~

Methods included from Literals

#float, #int, #null, #string

Constructor Details

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

Initializes a new SQL statement.

Parameters:

  • keyword (Symbol, Array<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.



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ronin/code/sql/statement.rb', line 68

def initialize(keyword,argument=nil,&block)
  @keyword  = keyword
  @argument = argument

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

Instance Attribute Details

#argumentObject? (readonly)

The statement's argument.

Returns:

  • (Object, nil)


50
51
52
# File 'lib/ronin/code/sql/statement.rb', line 50

def argument
  @argument
end

#keywordSymbol+ (readonly)

The statement name.

Returns:

  • (Symbol, Array<Symbol>)


45
46
47
# File 'lib/ronin/code/sql/statement.rb', line 45

def keyword
  @keyword
end