inossidabile / protector

Comfortable (seriously) white-list security restrictions for models on a field level
MIT License
270 stars 31 forks source link

Extend support from Range to any Enumerable #47

Closed aantono closed 10 years ago

aantono commented 10 years ago

Currently the access check supports value declaration checks either via defining a Range object, or by providing a Proc. Reality is that the values are not always in a Range, but could be an Array of objects that are not part of the sequence. i.e. list of roles, selectable options, etc. Changing https://github.com/inossidabile/protector/blob/master/lib/protector/dsl.rb#L215 to check when Enumerable instead of Range will cover all those cases. (The include? method comes from the Enumerable module for either of the classes anyways.

http://www.ruby-doc.org/core-1.9.3/Enumerable.html http://www.ruby-doc.org/core-1.9.3/Range.html#method-i-include-3F http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-include-3F http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-include-3F