public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Some performance goodness for inheritable attributes.

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
clemens (author)
Tue Sep 02 06:33:49 -0700 2008
jeremy (committer)
Tue Sep 02 15:55:23 -0700 2008
commit  288e947ae1737645985fde76f5382baaff700505
tree    3b48855cc336f3f1d04f2a14aa68b63ffc52ddba
parent  4d092ba2089de185cc8f5a8d16432b348e102046
...
164
165
166
167
168
 
 
169
170
171
172
 
173
174
175
176
177
 
 
178
179
180
...
194
195
196
197
 
198
199
200
...
164
165
166
 
 
167
168
169
170
171
 
172
173
174
175
 
 
176
177
178
179
180
...
194
195
196
 
197
198
199
200
0
@@ -164,17 +164,17 @@ module ActionController #:nodoc:
0
       # performance and have access to them as any normal template would.
0
       def layout(template_name, conditions = {}, auto = false)
0
         add_layout_conditions(conditions)
0
-        write_inheritable_attribute "layout", template_name
0
-        write_inheritable_attribute "auto_layout", auto
0
+        write_inheritable_attribute(:layout, template_name)
0
+        write_inheritable_attribute(:auto_layout, auto)
0
       end
0
 
0
       def layout_conditions #:nodoc:
0
-        @layout_conditions ||= read_inheritable_attribute("layout_conditions")
0
+        @layout_conditions ||= read_inheritable_attribute(:layout_conditions)
0
       end
0
 
0
       def default_layout(format) #:nodoc:
0
-        layout = read_inheritable_attribute("layout")
0
-        return layout unless read_inheritable_attribute("auto_layout")
0
+        layout = read_inheritable_attribute(:layout)
0
+        return layout unless read_inheritable_attribute(:auto_layout)
0
         @default_layout ||= {}
0
         @default_layout[format] ||= default_layout_with_format(format, layout)
0
         @default_layout[format]
0
@@ -194,7 +194,7 @@ module ActionController #:nodoc:
0
         end
0
 
0
         def add_layout_conditions(conditions)
0
-          write_inheritable_hash "layout_conditions", normalize_conditions(conditions)
0
+          write_inheritable_hash(:layout_conditions, normalize_conditions(conditions))
0
         end
0
 
0
         def normalize_conditions(conditions)
...
86
87
88
89
 
90
91
92
93
94
95
96
 
97
98
99
...
86
87
88
 
89
90
91
92
93
94
95
 
96
97
98
99
0
@@ -86,14 +86,14 @@ module ActionController #:nodoc:
0
           raise ArgumentError, "only one of either :only or :except are allowed"
0
         end
0
 
0
-        write_inheritable_array("session_options", [options])
0
+        write_inheritable_array(:session_options, [options])
0
       end
0
 
0
       # So we can declare session options in the Rails initializer.
0
       alias_method :session=, :session
0
 
0
       def cached_session_options #:nodoc:
0
-        @session_options ||= read_inheritable_attribute("session_options") || []
0
+        @session_options ||= read_inheritable_attribute(:session_options) || []
0
       end
0
 
0
       def session_options_for(request, action) #:nodoc:
...
920
921
922
923
 
924
925
926
927
928
 
929
930
931
...
953
954
955
956
 
957
958
959
960
961
 
962
963
964
965
966
 
967
968
969
970
971
 
972
973
974
...
992
993
994
995
 
996
997
998
...
920
921
922
 
923
924
925
926
927
 
928
929
930
931
...
953
954
955
 
956
957
958
959
960
 
961
962
963
964
965
 
966
967
968
969
970
 
971
972
973
974
...
992
993
994
 
995
996
997
998
0
@@ -920,12 +920,12 @@ module ActiveRecord #:nodoc:
0
       # To start from an all-closed default and enable attributes as needed,
0
       # have a look at +attr_accessible+.
0
       def attr_protected(*attributes)
0
-        write_inheritable_attribute("attr_protected", Set.new(attributes.map(&:to_s)) + (protected_attributes || []))
0
+        write_inheritable_attribute(:attr_protected, Set.new(attributes.map(&:to_s)) + (protected_attributes || []))
0
       end
0
 
0
       # Returns an array of all the attributes that have been protected from mass-assignment.
0
       def protected_attributes # :nodoc:
0
-        read_inheritable_attribute("attr_protected")
0
+        read_inheritable_attribute(:attr_protected)
0
       end
0
 
0
       # Specifies a white list of model attributes that can be set via
0
@@ -953,22 +953,22 @@ module ActiveRecord #:nodoc:
0
       #   customer.credit_rating = "Average"
0
       #   customer.credit_rating # => "Average"
0
       def attr_accessible(*attributes)
0
-        write_inheritable_attribute("attr_accessible", Set.new(attributes.map(&:to_s)) + (accessible_attributes || []))
0
+        write_inheritable_attribute(:attr_accessible, Set.new(attributes.map(&:to_s)) + (accessible_attributes || []))
0
       end
0
 
0
       # Returns an array of all the attributes that have been made accessible to mass-assignment.
0
       def accessible_attributes # :nodoc:
0
-        read_inheritable_attribute("attr_accessible")
0
+        read_inheritable_attribute(:attr_accessible)
0
       end
0
 
0
        # Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards.
0
        def attr_readonly(*attributes)
0
-         write_inheritable_attribute("attr_readonly", Set.new(attributes.map(&:to_s)) + (readonly_attributes || []))
0
+         write_inheritable_attribute(:attr_readonly, Set.new(attributes.map(&:to_s)) + (readonly_attributes || []))
0
        end
0
 
0
        # Returns an array of all the attributes that have been specified as readonly.
0
        def readonly_attributes
0
-         read_inheritable_attribute("attr_readonly")
0
+         read_inheritable_attribute(:attr_readonly)
0
        end
0
 
0
       # If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object,
0
@@ -992,7 +992,7 @@ module ActiveRecord #:nodoc:
0
 
0
       # Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values.
0
       def serialized_attributes
0
-        read_inheritable_attribute("attr_serialized") or write_inheritable_attribute("attr_serialized", {})
0
+        read_inheritable_attribute(:attr_serialized) or write_inheritable_attribute(:attr_serialized, {})
0
       end
0
 
0
 
...
283
284
285
286
 
287
288
289
290
291
292
 
293
294
295
...
283
284
285
 
286
287
288
289
290
291
 
292
293
294
295
0
@@ -283,13 +283,13 @@ module ActiveResource
0
         format = mime_type_reference_or_format.is_a?(Symbol) ?
0
           ActiveResource::Formats[mime_type_reference_or_format] : mime_type_reference_or_format
0
 
0
-        write_inheritable_attribute("format", format)
0
+        write_inheritable_attribute(:format, format)
0
         connection.format = format if site
0
       end
0
 
0
       # Returns the current format, default is ActiveResource::Formats::XmlFormat.
0
       def format
0
-        read_inheritable_attribute("format") || ActiveResource::Formats[:xml]
0
+        read_inheritable_attribute(:format) || ActiveResource::Formats[:xml]
0
       end
0
 
0
       # Sets the number of seconds after which requests to the REST API should time out.

Comments