Sha256: 3d75bef8612d623800ead180099603f750345aea2757065e3b94526116a5861f

Contents?: true

Size: 423 Bytes

Versions: 9

Compression:

Stored size: 423 Bytes

Contents

module Ecom
  module Core
    class FilterService
      def get_filtered_data(type, filters)
        positive = {}
        negative = {}
        obj = type.constantize
        filters.each { |f|
          if f[:cond] == 'P'
            positive[f[:key]] = f[:value]
          else
            negative[f[:key]] = f[:value]
          end
        }
        obj.where(positive).where.not(negative)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ecom_core-1.3.14 app/services/ecom/core/filter_service.rb
ecom_core-1.3.13 app/services/ecom/core/filter_service.rb
ecom_core-1.3.12 app/services/ecom/core/filter_service.rb
ecom_core-1.3.11 app/services/ecom/core/filter_service.rb
ecom_core-1.3.10 app/services/ecom/core/filter_service.rb
ecom_core-1.3.9 app/services/ecom/core/filter_service.rb
ecom_core-1.3.8 app/services/ecom/core/filter_service.rb
ecom_core-1.3.7 app/services/ecom/core/filter_service.rb
ecom_core-1.3.6 app/services/ecom/core/filter_service.rb