From 4290267959e8c91b8f2a4898d3fa33b15b8b7d57 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 29 Dec 2004 21:14:58 +0000 Subject: Moved support into Active Support git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@277 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../support/class_inheritable_attributes.rb | 40 ---------------------- 1 file changed, 40 deletions(-) delete mode 100644 activerecord/lib/active_record/support/class_inheritable_attributes.rb (limited to 'activerecord/lib/active_record/support/class_inheritable_attributes.rb') diff --git a/activerecord/lib/active_record/support/class_inheritable_attributes.rb b/activerecord/lib/active_record/support/class_inheritable_attributes.rb deleted file mode 100644 index 201932cf2d..0000000000 --- a/activerecord/lib/active_record/support/class_inheritable_attributes.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Allows attributes to be shared within an inheritance hierarchy, but where each descentent gets a copy of -# their parents' attributes, instead of just a pointer to the same. This means that the child can add elements -# to, for example, an array without those additions being shared with either their parent, siblings, or -# children, which is unlike the regular class-level attributes that are shared across the entire hierarchy. -module ClassInheritableAttributes # :nodoc: - def self.append_features(base) - super - base.extend(ClassMethods) - end - - module ClassMethods # :nodoc: - @@classes ||= {} - - def inheritable_attributes - @@classes[self] ||= {} - end - - def write_inheritable_attribute(key, value) - inheritable_attributes[key] = value - end - - def write_inheritable_array(key, elements) - write_inheritable_attribute(key, []) if read_inheritable_attribute(key).nil? - write_inheritable_attribute(key, read_inheritable_attribute(key) + elements) - end - - def read_inheritable_attribute(key) - inheritable_attributes[key] - end - - def reset_inheritable_attributes - inheritable_attributes.clear - end - - private - def inherited(child) - @@classes[child] = inheritable_attributes.dup - end - end -end -- cgit v1.2.3