aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/support/class_inheritable_attributes.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-29 21:09:59 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-29 21:09:59 +0000
commit8efa1513ed49783d8a7fd1dfccee93fa5e5f0d81 (patch)
treeaa7c56847820f73f190570219390c06e721cd70d /actionpack/lib/action_controller/support/class_inheritable_attributes.rb
parent5d0f633239e4f099755c36079d88d082dfdde543 (diff)
downloadrails-8efa1513ed49783d8a7fd1dfccee93fa5e5f0d81.tar.gz
rails-8efa1513ed49783d8a7fd1dfccee93fa5e5f0d81.tar.bz2
rails-8efa1513ed49783d8a7fd1dfccee93fa5e5f0d81.zip
Moved support files into Active Support
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@275 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/support/class_inheritable_attributes.rb')
-rw-r--r--actionpack/lib/action_controller/support/class_inheritable_attributes.rb41
1 files changed, 0 insertions, 41 deletions
diff --git a/actionpack/lib/action_controller/support/class_inheritable_attributes.rb b/actionpack/lib/action_controller/support/class_inheritable_attributes.rb
deleted file mode 100644
index 39312e8d5b..0000000000
--- a/actionpack/lib/action_controller/support/class_inheritable_attributes.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# Allows attributes to be shared within an inheritance hierarchy, but where each descendant 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