lib/rails_powergrid/ext/predicator.rb
# Create a substring for this kind of operator: AND/OR
Create a substring for this kind of operator: AND/OR
Create a substring for this kind of operator : AND / OR
def create_predicate parameters, grid, opts
      permits = grid.predicator_permit
      parameters.map do |k, v|
        if opts[:double_operators][k.to_sym]
          apply_double_operators(opts[:double_operators][k.to_sym], v, grid, opts)
        elsif op=opts[:operators][k.to_sym]
          field, value = v
          if permits.include?(v.first.to_sym)
            safeValue = if value.is_a?(Array)
              value.map{|v| ActiveRecord::Base::sanitize(v) }.join(", ")
            else
              ActiveRecord::Base::sanitize(value)
            end
            col = grid.get_column(field).apply_filter(grid.model, op, safeValue)
          else
            raise "Parameter unpermitted: `#{field}`, authorized = #{opts[:permit].inspect}"
          end
        end
      end.join(" ")
    end
def create_predicate parameters , grid , opts permits = grid . predicator_permit parameters . map do | k , v | if opts [ :double_operators ] [ k . to_sym ] apply_double_operators ( opts [ :double_operators ] [ k . to_sym ] , v , grid , opts ) elsif op = opts [ :operators ] [ k . to_sym ] field , value = v if permits . include? ( v . first . to_sym ) safeValue = if value . is_a? ( Array ) value . map { | v | ActiveRecord :: Base :: sanitize ( v ) } . join ( ", " ) else ActiveRecord :: Base :: sanitize ( value ) end col = grid . get_column ( field ) . apply_filter ( grid . model , op , safeValue ) else raise "Parameter unpermitted: `#{field}`, authorized = #{opts[:permit].inspect}" end end end . join ( " " ) end
Create a substring for this kind of operator: AND/OR
Create a substring for this kind of operator : AND / OR
parameters
<not_specific>
grid
<not_specific>
opts
<not_specific>