Class: Cassava::SelectClause

Inherits:
Struct
  • Object
show all
Defined in:
lib/cassava/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnsObject

Returns the value of attribute columns

Returns:

  • (Object)

    the current value of columns


170
171
172
# File 'lib/cassava/client.rb', line 170

def columns
  @columns
end

#count_booleanObject

Returns the value of attribute count_boolean

Returns:

  • (Object)

    the current value of count_boolean


170
171
172
# File 'lib/cassava/client.rb', line 170

def count_boolean
  @count_boolean
end

#tableObject

Returns the value of attribute table

Returns:

  • (Object)

    the current value of table


170
171
172
# File 'lib/cassava/client.rb', line 170

def table
  @table
end

Instance Method Details

#countObject

[View source]

171
172
173
# File 'lib/cassava/client.rb', line 171

def count
  self.class.new(table, _columns = nil, _count_boolean = true)
end

#to_sObject

[View source]

175
176
177
178
179
180
181
182
# File 'lib/cassava/client.rb', line 175

def to_s
  if count_boolean
    "SELECT COUNT(*) FROM #{table}"
  else
    self.columns ||= ['*']
    "SELECT #{columns.join(', ')} from #{table}"
  end
end