lib/sn_foil/searcher.rb in snfoil-0.4.2 vs lib/sn_foil/searcher.rb in snfoil-0.4.3

- old
+ new

@@ -61,11 +61,11 @@ return filtered_scope if setup.nil? if setup.is_a?(Symbol) || setup.is_a?(String) send(setup, filtered_scope, params) else - setup.call(filtered_scope, params) + instance_exec filtered_scope, params, &setup end end def apply_filters(filtered_scope, params) filters&.reduce(filtered_scope) do |i_scope, i_filter| @@ -76,10 +76,10 @@ def apply_filter(i_filter, filtered_scope, params) return filtered_scope unless filter_valid?(i_filter, params) return send(i_filter[:method], filtered_scope, params) if i_filter[:method] - i_filter[:block].call(filtered_scope, params) + instance_exec filtered_scope, params, &i_filter[:block] end def filter_valid?(i_filter, params) return false if !i_filter[:if].nil? && i_filter[:if].call(params) == false return false if !i_filter[:unless].nil? && i_filter[:unless].call(params) == true