Class: Ronin::SQL::Field
- Inherits:
-
Struct
- Object
- Struct
- Ronin::SQL::Field
- Defined in:
- lib/ronin/sql/field.rb
Overview
Represents a SQL column, table or database name.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Class Method Summary collapse
-
.parse(name) ⇒ Field
Parses a field.
Instance Method Summary collapse
-
#initialize(name, parent = nil) ⇒ Field
constructor
Initializes the new field.
-
#method_missing(name, *arguments) ⇒ Object
protected
Allows accessing columns from tables or tables from databases.
Methods included from Emittable
#emitter, #inspect, #to_s, #to_sql
Methods included from Operators
#!, #!=, #%, #&, #*, #+, #+@, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #and, #as, #glob, #in, #is, #is_not, #like, #match, #not, #or, #regexp, #|, #~
Constructor Details
#initialize(name, parent = nil) ⇒ Field
Initializes the new field.
47 48 49 |
# File 'lib/ronin/sql/field.rb', line 47 def initialize(name,parent=nil) super(name.to_s,parent) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arguments) ⇒ Object (protected)
Allows accessing columns from tables or tables from databases.
84 85 86 87 88 89 90 91 92 93 94 |
# 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 |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
33 34 35 |
# File 'lib/ronin/sql/field.rb', line 33 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent
33 34 35 |
# File 'lib/ronin/sql/field.rb', line 33 def parent @parent end |
Class Method Details
.parse(name) ⇒ Field
Parses a field.
59 60 61 62 63 64 65 66 |
# 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 |