class Ronin::SQL::Field
Represents a SQL
column, table or database name.
@api semipublic
Public Class Methods
new(name,parent=nil)
click to toggle source
Initializes the new field.
@param [String] name
The name of the field.
@param [Field] parent
The parent of the field.
Calls superclass method
# File lib/ronin/sql/field.rb, line 47 def initialize(name,parent=nil) super(name.to_s,parent) end
parse(name)
click to toggle source
Parses a field.
@param [String] name
@return [Field]
The parsed field.
# File lib/ronin/sql/field.rb, line 59 def self.parse(name) names = name.to_s.split('.',3) field = nil names.each { |name| field = new(name,field) } return field end
Protected Instance Methods
method_missing(name,*arguments)
click to toggle source
Allows accessing columns from tables or tables from databases.
@param [Symbol] name
The sub-field name.
@example
db.users
@example
users.id
# File lib/ronin/sql/field.rb, line 84 def method_missing(name,*arguments) unless arguments.empty? raise(ArgumentError,"canot access columns or tables with arguments") end if (self.parent.nil? || self.parent.parent.nil?) Field.new(name,self) else raise(NoMethodError,"cannot access coumns from other columns") end end