Class: SQLObject
- Inherits:
-
Object
- Object
- SQLObject
- Defined in:
- lib/sqlobject.rb
Overview
Main class for all objects. All other entities should inherit this class.
Direct Known Subclasses
SQLAliasedList, SQLColumn, SQLCondList, SQLConditional, SQLConstructor, SQLConstructor::GenericQuery, SQLValList, SQLValue
Instance Attribute Summary collapse
-
#alias ⇒ Object
Returns the value of attribute alias.
-
#inline ⇒ Object
Returns the value of attribute inline.
-
#name ⇒ Object
Returns the value of attribute name.
-
#separator ⇒ Object
Returns the value of attribute separator.
Class Method Summary collapse
-
.get(*list) ⇒ Object
Convert values to the corresponding internal data types.
Instance Method Summary collapse
-
#_name(name) ⇒ Object
Set object’s name for further named processing.
-
#_string ⇒ Object
attr_reader for @string, actually an alias to to_s().
-
#_string=(val) ⇒ Object
attr_writer for @string.
-
#initialize ⇒ SQLObject
constructor
Do we really need a constructor here?.
-
#to_s ⇒ Object
Store string representation in @string after the first call.
Constructor Details
#initialize ⇒ SQLObject
Do we really need a constructor here?
12 13 14 15 16 17 |
# File 'lib/sqlobject.rb', line 12 def initialize @string = nil @alias = nil @name = nil @inline = nil end |
Instance Attribute Details
#alias ⇒ Object
Returns the value of attribute alias.
7 8 9 |
# File 'lib/sqlobject.rb', line 7 def alias @alias end |
#inline ⇒ Object
Returns the value of attribute inline.
7 8 9 |
# File 'lib/sqlobject.rb', line 7 def inline @inline end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/sqlobject.rb', line 7 def name @name end |
#separator ⇒ Object
Returns the value of attribute separator.
7 8 9 |
# File 'lib/sqlobject.rb', line 7 def separator @separator end |
Class Method Details
.get(*list) ⇒ Object
Convert values to the corresponding internal data types
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/sqlobject.rb', line 52 def self.get ( *list ) list.map! do |expr| if expr.is_a? SQLObject # inline queries go in parens: if expr.class == SQLConstructor || expr.is_a?( SQLConstructor::GenericQuery ) expr.inline = true end expr elsif expr.is_a? Array or expr.is_a? Range SQLValList.new *expr.to_a elsif expr.is_a? Hash SQLAliasedList.new expr elsif expr.is_a? Symbol SQLColumn.new( expr ) else SQLValue.new( expr ) end end # Return array or scalar, depending on the number of function arguments list.length == 1 ? list[0] : list end |
Instance Method Details
#_name(name) ⇒ Object
Set object’s name for further named processing
22 23 24 25 |
# File 'lib/sqlobject.rb', line 22 def _name ( name ) @name = name.to_s return self end |
#_string ⇒ Object
attr_reader for @string, actually an alias to to_s().
38 39 40 |
# File 'lib/sqlobject.rb', line 38 def _string to_s end |
#_string=(val) ⇒ Object
attr_writer for @string
45 46 47 |
# File 'lib/sqlobject.rb', line 45 def _string= ( val ) @string = val end |
#to_s ⇒ Object
Store string representation in @string after the first call
30 31 32 33 |
# File 'lib/sqlobject.rb', line 30 def to_s return @string if @string @string = self.to_s end |