Class: Ronin::SQL::Statement

Inherits:
Struct
  • Object
show all
Includes:
Clauses, Emittable, Literals, Operators
Defined in:
lib/ronin/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, #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.



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

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

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

Instance Attribute Details

#argumentObject

Returns the value of attribute argument

Returns:

  • (Object)

    the current value of argument



36
37
38
# File 'lib/ronin/sql/statement.rb', line 36

def argument
  @argument
end

#keywordObject

Returns the value of attribute keyword

Returns:

  • (Object)

    the current value of keyword



36
37
38
# File 'lib/ronin/sql/statement.rb', line 36

def keyword
  @keyword
end