Class: Card::Query::SqlStatement
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#distinct ⇒ Object
Returns the value of attribute distinct.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#group ⇒ Object
Returns the value of attribute group.
-
#joins ⇒ Object
Returns the value of attribute joins.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#order ⇒ Object
Returns the value of attribute order.
-
#tables ⇒ Object
Returns the value of attribute tables.
Instance Method Summary collapse
-
#initialize ⇒ SqlStatement
constructor
A new instance of SqlStatement.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ SqlStatement
Returns a new instance of SqlStatement.
76 77 78 79 |
# File 'lib/card/query.rb', line 76 def initialize @fields, @joins, @conditions = [],[],[],[] @tables = @group = @order = @limit = @offset = @distinct = nil end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
74 75 76 |
# File 'lib/card/query.rb', line 74 def conditions @conditions end |
#distinct ⇒ Object
Returns the value of attribute distinct.
74 75 76 |
# File 'lib/card/query.rb', line 74 def distinct @distinct end |
#fields ⇒ Object
Returns the value of attribute fields.
74 75 76 |
# File 'lib/card/query.rb', line 74 def fields @fields end |
#group ⇒ Object
Returns the value of attribute group.
74 75 76 |
# File 'lib/card/query.rb', line 74 def group @group end |
#joins ⇒ Object
Returns the value of attribute joins.
74 75 76 |
# File 'lib/card/query.rb', line 74 def joins @joins end |
#limit ⇒ Object
Returns the value of attribute limit.
74 75 76 |
# File 'lib/card/query.rb', line 74 def limit @limit end |
#offset ⇒ Object
Returns the value of attribute offset.
74 75 76 |
# File 'lib/card/query.rb', line 74 def offset @offset end |
#order ⇒ Object
Returns the value of attribute order.
74 75 76 |
# File 'lib/card/query.rb', line 74 def order @order end |
#tables ⇒ Object
Returns the value of attribute tables.
74 75 76 |
# File 'lib/card/query.rb', line 74 def tables @tables end |
Instance Method Details
#to_s ⇒ Object
81 82 83 84 85 86 |
# File 'lib/card/query.rb', line 81 def to_s select = fields.reject(&:blank?) * ', ' where = conditions.reject(&:blank?) * ' and ' ['(SELECT', distinct, select, 'FROM', tables, joins, 'WHERE', where, group, order, limit, offset, ')'].compact * ' ' end |