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

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