Module: Searchlogic::Search::Conditions

Included in:
Searchlogic::Search
Defined in:
lib/searchlogic/search/conditions.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) compact_conditions



9
10
11
# File 'lib/searchlogic/search/conditions.rb', line 9

def compact_conditions
  Hash[conditions.select { |k,v| !v.blank? }]
end

- (Object) conditions

Returns a hash of the current conditions set.



5
6
7
# File 'lib/searchlogic/search/conditions.rb', line 5

def conditions
  mass_conditions.clone.merge(@conditions)
end

- (Object) conditions=(values)

Accepts a hash of conditions.



14
15
16
17
18
19
20
21
# File 'lib/searchlogic/search/conditions.rb', line 14

def conditions=(values)
  values.each do |condition, value|
    mass_conditions[condition.to_sym] = value
    value.delete_if { |v| ignore_value?(v) } if value.is_a?(Array)
    next if ignore_value?(value)
    send("#{condition}=", value)
  end
end

- (Object) delete(*names)

Delete a condition from the search. Since conditions map to named scopes, if a named scope accepts a parameter there is no way to actually delete the scope if you do not want it anymore. A nil value might be meaningful to that scope.



27
28
29
30
31
32
33
# File 'lib/searchlogic/search/conditions.rb', line 27

def delete(*names)
  names.each do |name|
    @conditions.delete(name.to_sym)
    mass_conditions.delete(name)
  end
  self
end