Class: Card::Query::SqlStatement

Inherits:
Object
  • Object
show all
Defined in:
lib/card/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSqlStatement

Returns a new instance of SqlStatement.



64
65
66
67
# File 'lib/card/query.rb', line 64

def initialize
  @fields, @joins, @conditions = [],[],[],[]
  @tables, @group, @order, @limit, @offset = "","","","",""
end

Instance Attribute Details

#conditionsObject

Returns the value of attribute conditions.



62
63
64
# File 'lib/card/query.rb', line 62

def conditions
  @conditions
end

#fieldsObject

Returns the value of attribute fields.



62
63
64
# File 'lib/card/query.rb', line 62

def fields
  @fields
end

#groupObject

Returns the value of attribute group.



62
63
64
# File 'lib/card/query.rb', line 62

def group
  @group
end

#joinsObject

Returns the value of attribute joins.



62
63
64
# File 'lib/card/query.rb', line 62

def joins
  @joins
end

#limitObject

Returns the value of attribute limit.



62
63
64
# File 'lib/card/query.rb', line 62

def limit
  @limit
end

#offsetObject

Returns the value of attribute offset.



62
63
64
# File 'lib/card/query.rb', line 62

def offset
  @offset
end

#orderObject

Returns the value of attribute order.



62
63
64
# File 'lib/card/query.rb', line 62

def order
  @order
end

#tablesObject

Returns the value of attribute tables.



62
63
64
# File 'lib/card/query.rb', line 62

def tables
  @tables
end

Instance Method Details

#to_sObject



69
70
71
72
73
# File 'lib/card/query.rb', line 69

def to_s
  select = fields.reject(&:blank?) * ', '
  where = conditions.reject(&:blank?) * ' and '
  ['(SELECT', select, 'FROM', tables, joins, 'WHERE', where, group, order, limit, offset, ')'].compact * ' '
end