Sha256: 9df82b614f047fdfddb3e506fd948daf12e08236bf29c323613c21bd08058afc

Contents?: true

Size: 666 Bytes

Versions: 53

Compression:

Stored size: 666 Bytes

Contents

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(/\(.+/m, '')
      end
    end

    class WhiteList < PermissionSet

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

    class BlackList < PermissionSet

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

Version data entries

53 entries across 44 versions & 9 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/activemodel-3.2.22.5/lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.22.5 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.22.4 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.22.3 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.22.2 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.22.1 lib/active_model/mass_assignment_security/permission_set.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.12/lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.22 lib/active_model/mass_assignment_security/permission_set.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activemodel-3.2.12/lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.21 lib/active_model/mass_assignment_security/permission_set.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/activemodel-3.2.18/lib/active_model/mass_assignment_security/permission_set.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.18/lib/active_model/mass_assignment_security/permission_set.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/activemodel-3.2.18/lib/active_model/mass_assignment_security/permission_set.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/activemodel-3.2.18/lib/active_model/mass_assignment_security/permission_set.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/activemodel-3.2.18/lib/active_model/mass_assignment_security/permission_set.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.18/lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.20 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.19 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.18 lib/active_model/mass_assignment_security/permission_set.rb
activemodel-3.2.17 lib/active_model/mass_assignment_security/permission_set.rb