Sha256: 30373c25d7f164004b821cbfb9efdf74a12eb34713edddbb4551e78dd6002cd4
Contents?: true
Size: 623 Bytes
Versions: 11
Compression:
Stored size: 623 Bytes
Contents
require_relative '../filter_decorator.rb' class Has_not_field_filter_decorator < Filter_decorator def initialize(filter, field) super(filter) self.field = field end def apply(filtering_obj) if filtering_obj.is_a?(Array) super(filtering_obj).select do |student| student_value = student.send(self.field).to_s student_value.nil? || student_value.empty? end else query = super(filtering_obj) condition = query.include?("WHERE") ? "AND" : "WHERE" "#{query} #{condition} (#{field} = '' OR #{field} IS NULL)" end end private attr_accessor :field end
Version data entries
11 entries across 11 versions & 1 rubygems