Class: SelectClause

Inherits:
Object show all
Defined in:
lib/activeleopard/query_clauses/select_clause.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = []) ⇒ SelectClause

Returns a new instance of SelectClause.



4
5
6
7
# File 'lib/activeleopard/query_clauses/select_clause.rb', line 4

def initialize(params = [])
  @distinct = false
  @params = params
end

Instance Attribute Details

#distinctObject

Returns the value of attribute distinct.



2
3
4
# File 'lib/activeleopard/query_clauses/select_clause.rb', line 2

def distinct
  @distinct
end

#paramsObject

Returns the value of attribute params.



2
3
4
# File 'lib/activeleopard/query_clauses/select_clause.rb', line 2

def params
  @params
end

Instance Method Details

#as_sqlObject



9
10
11
12
13
# File 'lib/activeleopard/query_clauses/select_clause.rb', line 9

def as_sql
  "SELECT " +
  "#{distinct ? 'DISTINCT ' : ''}" +
  "#{params_as_sql}"
end

#params_as_sqlObject



15
16
17
# File 'lib/activeleopard/query_clauses/select_clause.rb', line 15

def params_as_sql
  params.map(&:to_s).join(', ')
end