Class: ThinkingSphinx::ActiveRecord::SQLBuilder::ClauseBuilder
- Inherits:
-
Object
- Object
- ThinkingSphinx::ActiveRecord::SQLBuilder::ClauseBuilder
- Defined in:
- lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb
Instance Method Summary collapse
- #add_clause(clause) ⇒ Object
- #compose(*additions) ⇒ Object
-
#initialize(first_element) ⇒ ClauseBuilder
constructor
A new instance of ClauseBuilder.
- #separated(by = ', ') ⇒ Object
Constructor Details
#initialize(first_element) ⇒ ClauseBuilder
Returns a new instance of ClauseBuilder.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb', line 6 def initialize(first_element) @clauses = [first_element] end |
Instance Method Details
#add_clause(clause) ⇒ Object
16 17 18 |
# File 'lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb', line 16 def add_clause(clause) @clauses += Array(clause) end |
#compose(*additions) ⇒ Object
10 11 12 13 14 |
# File 'lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb', line 10 def compose(*additions) additions.each &method(:add_clause) self end |
#separated(by = ', ') ⇒ Object
20 21 22 |
# File 'lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb', line 20 def separated(by = ', ') clauses.flatten.compact.join(by) end |