Class: ThinkingSphinx::ActiveRecord::SQLBuilder::ClauseBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(first_element) ⇒ ClauseBuilder



4
5
6
# File 'lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb', line 4

def initialize(first_element)
  @clauses = [first_element]
end

Instance Method Details

#add_clause(clause) ⇒ Object



14
15
16
# File 'lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb', line 14

def add_clause(clause)
  @clauses += Array(clause)
end

#compose(*additions) ⇒ Object



8
9
10
11
12
# File 'lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb', line 8

def compose(*additions)
  additions.each &method(:add_clause)

  self
end

#separated(by = ', ') ⇒ Object



18
19
20
# File 'lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb', line 18

def separated(by = ', ')
  clauses.flatten.compact.join(by)
end