Module: Searchgasm::ActiveRecord::Associations::AssociationCollection

Defined in:
lib/searchgasm/active_record/associations.rb

Instance Method Summary collapse

Instance Method Details

#build_conditions(options = {}, &block) ⇒ Object

See build_conditions under Searchgasm::ActiveRecord::Base. This is the same thing but for associations.



16
17
18
19
20
# File 'lib/searchgasm/active_record/associations.rb', line 16

def build_conditions(options = {}, &block)
  conditions = @reflection.klass.build_conditions(options, &block)
  conditions.scope = scope(:find)[:conditions]
  conditions
end

#build_conditions!(options = {}, &block) ⇒ Object

See build_conditions! under Searchgasm::ActiveRecord::Base. This is the same thing but for associations.



23
24
25
26
27
# File 'lib/searchgasm/active_record/associations.rb', line 23

def build_conditions!(options = {}, &block)
  conditions = @reflection.klass.build_conditions!(options, &block)
  conditions.scope = scope(:find)[:conditions]
  conditions
end

#build_search(options = {}, &block) ⇒ Object

See build_search under Searchgasm::ActiveRecord::Base. This is the same thing but for associations.



30
31
32
33
34
# File 'lib/searchgasm/active_record/associations.rb', line 30

def build_search(options = {}, &block)
  conditions = @reflection.klass.build_search(options, &block)
  conditions.scope = scope(:find)[:conditions]
  conditions
end

#build_search!(options = {}, &block) ⇒ Object

See build_conditions! under Searchgasm::ActiveRecord::Base. This is the same thing but for associations.



37
38
39
40
41
# File 'lib/searchgasm/active_record/associations.rb', line 37

def build_search!(options = {}, &block)
  conditions = @reflection.klass.build_search!(options, &block)
  conditions.scope = scope(:find)[:conditions]
  conditions
end

#find_with_searchgasm(*args) ⇒ Object

This is an alias method chain. It hook into ActiveRecord’s “find” method for associations and checks to see if Searchgasm should get involved.



9
10
11
12
13
# File 'lib/searchgasm/active_record/associations.rb', line 9

def find_with_searchgasm(*args)
  options = args.extract_options!
  args << sanitize_options_with_searchgasm(options)
  find_without_searchgasm(*args)
end