Class: Ronin::SQL::InjectionExpr Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Emittable

#emitter, #inspect, #to_s

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(initial_value) ⇒ InjectionExpr

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the new expression to inject.

Parameters:

  • initial_value (String, Integer, Float, Array, Symbol)

    The initial value for the expression.

Since:

  • 1.1.0



54
55
56
# File 'lib/ronin/sql/injection_expr.rb', line 54

def initialize(initial_value)
  @expression = initial_value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ronin::SQL::Fields

Instance Attribute Details

#expressionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The expression that will be injected

Since:

  • 1.1.0



46
47
48
# File 'lib/ronin/sql/injection_expr.rb', line 46

def expression
  @expression
end

Instance Method Details

#and {|(self)| ... } ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Appends an AND expression to the injection.

Yields:

  • ((self))

    The return value of the block will be used as the right-hand side operand. If the block accepts an argument, it will be called with the injection expression.

Returns:

  • (self)

Since:

  • 1.1.0



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

def and(&block)
  value = case block.arity
          when 0 then instance_eval(&block)
          else        block.call(self)
          end

  @expression = BinaryExpr.new(@expression,:AND,value)
  return self
end

#or {|(self)| ... } ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Appends an OR expression to the injection.

Yields:

  • ((self))

    The return value of the block will be used as the right-hand side operand. If the block accepts an argument, it will be called with the injection expression.

Returns:

  • (self)

Since:

  • 1.1.0



88
89
90
91
92
93
94
95
96
# File 'lib/ronin/sql/injection_expr.rb', line 88

def or(&block)
  value = case block.arity
          when 0 then instance_eval(&block)
          else        block.call(self)
          end

  @expression = BinaryExpr.new(@expression,:OR,value)
  return self
end

#to_sql(options = {}) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Emits the injection expression.

Parameters:

Returns:

Since:

  • 1.1.0



107
108
109
# File 'lib/ronin/sql/injection_expr.rb', line 107

def to_sql(options={})
  emitter(options).emit(@expression)
end