Class: SelectClause
- Defined in:
- lib/activeleopard/query_clauses/select_clause.rb
Instance Attribute Summary collapse
-
#distinct ⇒ Object
Returns the value of attribute distinct.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #as_sql ⇒ Object
-
#initialize(params = []) ⇒ SelectClause
constructor
A new instance of SelectClause.
- #params_as_sql ⇒ Object
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
#distinct ⇒ Object
Returns the value of attribute distinct.
2 3 4 |
# File 'lib/activeleopard/query_clauses/select_clause.rb', line 2 def distinct @distinct end |
#params ⇒ Object
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_sql ⇒ Object
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_sql ⇒ Object
15 16 17 |
# File 'lib/activeleopard/query_clauses/select_clause.rb', line 15 def params_as_sql params.map(&:to_s).join(', ') end |