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.20 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.1.10 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.19 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.1.9 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.18 lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.1.8 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.17 lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.6.3 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.1.7 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.0.16 lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.6.2 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb
dirty_history-0.6.1 dirty_history/ruby/1.9.1/gems/activemodel-3.1.1/lib/active_model/mass_assignment_security/permission_set.rb