Sha256: 76f91c6deceae6ef05490d178a5e30325f357165148968d5fa4e4942d182e5f8

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 Bytes

Contents

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)
      ids = as_array(filters[:ids])
      @scope = @scope.where(asset_id: ids) if ids

      name = filters[:name].presence
      return unless name
      @scope = @scope.where('LOWER(name) LIKE ?', "%#{name}%".downcase)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 app/models/landable/asset_search_engine.rb
landable-1.13.2 app/models/landable/asset_search_engine.rb