123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Criteria::Permission

Relationships & Source Files
Defined in: lib/mongoid/criteria/permission.rb

Overview

Mixin module for ::Mongoid::Criteria which adds strong parameters validation when using ActionController::Parameters objects as arguments to condition methods.

Instance Method Summary

Instance Method Details

#should_permit?(criteria) ⇒ true | false (private)

This method is for internal use only.

Ensure that the criteria are permitted.

Examples:

Ignoring ActionController::Parameters

should_permit?({_id: ActionController::Parameters.new("$size" => 1)})

Parameters:

  • criteria (Object)

Returns:

  • (true | false)

    if should permit

[ GitHub ]

  
# File 'lib/mongoid/criteria/permission.rb', line 63

def should_permit?(criteria)
  if criteria.respond_to?(:permitted?)
    return criteria.permitted?
  elsif criteria.respond_to?(:each)
    criteria.each do |criterion|
      return false unless should_permit?(criterion)
    end
  end

  true
end