blob: a1fcdf1a38bd5195f95eeac8fbc383e4b73b453d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
require 'set'
module ActiveModel
module MassAssignmentSecurity
class PermissionSet < Set
def +(values)
super(values.map(&:to_s))
end
def include?(key)
super(remove_multiparameter_id(key))
end
def deny?(key)
raise NotImplementedError, "#deny?(key) suppose to be overwritten"
end
protected
def remove_multiparameter_id(key)
key.to_s.gsub(/\(.+/, '')
end
end
class WhiteList < PermissionSet
def deny?(key)
!include?(key)
end
end
class BlackList < PermissionSet
def deny?(key)
include?(key)
end
end
end
end
|