in a project we are enforcing permissions by wrapping active record objects and arrays of ar objects in a proxy class. this proxy class is a BasicObject that uses #method_missing to send methods to a target (the ar object) i believe this is how :has_many association/reflection works (at least in 2.x). i wanted to benchmark this technique against simply extending ar objects on the fly with a permissions module. now i realize extending objects create entirely new singleton classes but i just wanted to test this method out. i thought i could simply over-write the #read_attribute and #write_attribute methods and enforce permissions that way but it seems not all dynamic attribute methods utilize these methods. all attribute setter methods look like they are routed through #write_attribute, but not all getter methods are routed through #read_attribute - as far as i can tell only datetime getters are routed through #read_attribute. all other getter methods touch the @attributes instance variable directly. does anyone know why the dynamic getter attribute methods behave this way? wouldn''t it be prudent to have one end-all-be-all method that all read attribute methods go through? (excluding before type casting lookups) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
after looking deeper in ActiveModel i found that all dynamically generated attribute methods are included in a dynamic anonymous module. it can be accessed from an active record class via .generated_attribute_methods (User.generated_attribute_methods) i was eventually able to alias all generated methods and set up a permission chain upon object extension - this method works but seems very HEAVY. would be nicer if all attribute manipulation went through #read_attribute and #write_attribute. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
after looking deeper in ActiveModel i found that all dynamically generated attribute methods are included in a dynamic anonymous module. it can be accessed from an active record class via .generated_attribute_methods (User.generated_attribute_methods) i was eventually able to alias all generated methods and set up a permission chain upon object extension - this method works but seems very HEAVY. would be nicer if all attribute manipulation went through #read_attribute and #write_attribute. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.