File: inheritance.rb

package info (click to toggle)
ruby-protected-attributes 1.0.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 304 kB
  • ctags: 382
  • sloc: ruby: 1,977; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module ActiveRecord
  module MassAssignmentSecurity
    module Inheritance
      extend ActiveSupport::Concern

      module ClassMethods
      private
        # Detect the subclass from the inheritance column of attrs. If the inheritance column value
        # is not self or a valid subclass, raises ActiveRecord::SubclassNotFound
        # If this is a StrongParameters hash, and access to inheritance_column is not permitted,
        # this will ignore the inheritance column and return nil
        def subclass_from_attributes?(attrs)
          active_authorizer[:default].deny?(inheritance_column) ? nil : super
        end

        # Support Active Record <= 4.0.3, which uses the old method signature.
        def subclass_from_attrs(attrs)
          active_authorizer[:default].deny?(inheritance_column) ? nil : super
        end
      end
    end
  end
end