app/models/landable/asset_search_engine.rb in landable-1.13.1 vs app/models/landable/asset_search_engine.rb in landable-1.13.2
- old
+ new
@@ -1,20 +1,19 @@
-require_dependency "landable/search_engine"
-require_dependency "landable/asset"
+require_dependency 'landable/search_engine'
+require_dependency 'landable/asset'
module Landable
class AssetSearchEngine < SearchEngine
def initialize(filters)
super Asset.all, filters
end
def filter_by!(filters)
- if ids = as_array(filters[:ids])
- @scope = @scope.where(asset_id: ids)
- end
+ ids = as_array(filters[:ids])
+ @scope = @scope.where(asset_id: ids) if ids
- if name = filters[:name].presence
- @scope = @scope.where('LOWER(name) LIKE ?', "%#{name}%".downcase)
- end
+ name = filters[:name].presence
+ return unless name
+ @scope = @scope.where('LOWER(name) LIKE ?', "%#{name}%".downcase)
end
end
end