Module: Protector::Adapters::ActiveRecord::Base::ClassMethods
- Defined in:
- lib/protector/adapters/active_record/base.rb
Instance Method Summary collapse
-
#define_method_attribute(name) ⇒ Object
Wraps every
.field
method with a check against DSL::Meta::Box#readable?.
Instance Method Details
#define_method_attribute(name) ⇒ Object
Wraps every .field
method with a check against DSL::Meta::Box#readable?
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/protector/adapters/active_record/base.rb', line 60 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 |