module Protector::Adapters::ActiveRecord::Base::ClassMethods

Public Instance Methods

define_method_attribute(name) click to toggle source

Wraps every ‘.field` method with a check against {Protector::DSL::Meta::Box#readable?}

Calls superclass method
# File lib/protector/adapters/active_record/base.rb, line 67
          def define_method_attribute(name)
            super

            # Show some <3 to composite primary keys
            unless primary_key == name || Array(primary_key).include?(name)
              generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
                alias_method #{"#{name}_unprotected".inspect}, #{name.inspect}

                def #{name}
                  if !protector_subject? || protector_meta.readable?(#{name.inspect})
                    #{name}_unprotected
                  else
                    nil
                  end
                end
              STR
            end
          end
protector_meta() click to toggle source

Storage of {Protector::DSL::Meta}

# File lib/protector/adapters/active_record/base.rb, line 60
def protector_meta
  ensure_protector_meta!(Protector::Adapters::ActiveRecord) do
    column_names
  end
end