Class: Ronin::SQL::Clause

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



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

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

  if block
    self.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::SQL::Fields

Instance Attribute Details

#argumentObject

Returns the value of attribute argument

Returns:

  • (Object)

    the current value of argument



37
38
39
# File 'lib/ronin/sql/clause.rb', line 37

def argument
  @argument
end

#keywordObject

Returns the value of attribute keyword

Returns:

  • (Object)

    the current value of keyword



37
38
39
# File 'lib/ronin/sql/clause.rb', line 37

def keyword
  @keyword
end