Class: Ronin::Code::SQL::Clause

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

Overview

Represents a SQL Clause.

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, #statement, #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

Methods included from Literals

#float, #int, #null, #string

Constructor Details

#initialize(keyword, argument = nil) {|(clause)| ... } ⇒ Clause

Initializes the SQL clause.

Parameters:

  • keyword (Symbol)

    The name of the clause.

  • argument (Object, nil) (defaults to: nil)

    Additional argument for the clause.

Yields:

  • ((clause))

    If a block is given, the return value will be used as the argument.

Yield Parameters:

  • clause (Clause)

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



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ronin/code/sql/clause.rb', line 70

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

  if block
    @argument = 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

#argumentObject? (readonly)

The clause's argument.

Returns:

  • (Object, nil)


52
53
54
# File 'lib/ronin/code/sql/clause.rb', line 52

def argument
  @argument
end

#keywordSymbol (readonly)

The name of the clause.

Returns:

  • (Symbol)


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

def keyword
  @keyword
end