Sha256: 109dd5bc5720770d25d6e8ab66b8e75aec6a37e243977a8d86d20d8be043db22

Contents?: true

Size: 692 Bytes

Versions: 92

Compression:

Stored size: 692 Bytes

Contents

require 'set'
require 'active_model/mass_assignment_security/sanitizer'

module ActiveModel
  module MassAssignmentSecurity
    class PermissionSet < Set
      attr_accessor :logger

      def +(values)
        super(values.map(&:to_s))
      end

      def include?(key)
        super(remove_multiparameter_id(key))
      end

    protected

      def remove_multiparameter_id(key)
        key.to_s.gsub(/\(.+/, '')
      end
    end

    class WhiteList < PermissionSet
      include Sanitizer

      def deny?(key)
        !include?(key)
      end
    end

    class BlackList < PermissionSet
      include Sanitizer

      def deny?(key)
        include?(key)
      end
    end
  end
end

Version data entries

92 entries across 92 versions & 2 rubygems

Version Path
activemodel-3.0.6.rc2 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.6.rc1 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.5 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.5.rc1 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.4 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.4.rc1 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.3 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.2 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.1 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.0 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.0.rc2 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.0.rc lib/active_model/mass_assignment_security/permission_set.rb