aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Kofler <clemens@railway.at>2008-09-02 15:33:49 +0200
committerJeremy Kemper <jeremy@bitsweat.net>2008-09-03 00:55:23 +0200
commit288e947ae1737645985fde76f5382baaff700505 (patch)
tree3b48855cc336f3f1d04f2a14aa68b63ffc52ddba
parent4d092ba2089de185cc8f5a8d16432b348e102046 (diff)
downloadrails-288e947ae1737645985fde76f5382baaff700505.tar.gz
rails-288e947ae1737645985fde76f5382baaff700505.tar.bz2
rails-288e947ae1737645985fde76f5382baaff700505.zip
Some performance goodness for inheritable attributes.
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
-rw-r--r--actionpack/lib/action_controller/layout.rb12
-rw-r--r--actionpack/lib/action_controller/session_management.rb4
-rw-r--r--activerecord/lib/active_record/base.rb14
-rw-r--r--activeresource/lib/active_resource/base.rb4
4 files changed, 17 insertions, 17 deletions
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index 8432a008eb..3631ce86af 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -164,17 +164,17 @@ module ActionController #:nodoc:
# performance and have access to them as any normal template would.
def layout(template_name, conditions = {}, auto = false)
add_layout_conditions(conditions)
- write_inheritable_attribute "layout", template_name
- write_inheritable_attribute "auto_layout", auto
+ write_inheritable_attribute(:layout, template_name)
+ write_inheritable_attribute(:auto_layout, auto)
end
def layout_conditions #:nodoc:
- @layout_conditions ||= read_inheritable_attribute("layout_conditions")
+ @layout_conditions ||= read_inheritable_attribute(:layout_conditions)
end
def default_layout(format) #:nodoc:
- layout = read_inheritable_attribute("layout")
- return layout unless read_inheritable_attribute("auto_layout")
+ layout = read_inheritable_attribute(:layout)
+ return layout unless read_inheritable_attribute(:auto_layout)
@default_layout ||= {}
@default_layout[format] ||= default_layout_with_format(format, layout)
@default_layout[format]
@@ -194,7 +194,7 @@ module ActionController #:nodoc:
end
def add_layout_conditions(conditions)
- write_inheritable_hash "layout_conditions", normalize_conditions(conditions)
+ write_inheritable_hash(:layout_conditions, normalize_conditions(conditions))
end
def normalize_conditions(conditions)
diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb
index 80a3ddd2c5..f5a1155a46 100644
--- a/actionpack/lib/action_controller/session_management.rb
+++ b/actionpack/lib/action_controller/session_management.rb
@@ -86,14 +86,14 @@ module ActionController #:nodoc:
raise ArgumentError, "only one of either :only or :except are allowed"
end
- write_inheritable_array("session_options", [options])
+ write_inheritable_array(:session_options, [options])
end
# So we can declare session options in the Rails initializer.
alias_method :session=, :session
def cached_session_options #:nodoc:
- @session_options ||= read_inheritable_attribute("session_options") || []
+ @session_options ||= read_inheritable_attribute(:session_options) || []
end
def session_options_for(request, action) #:nodoc:
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index bc6d61301f..2367277c03 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -920,12 +920,12 @@ module ActiveRecord #:nodoc:
# To start from an all-closed default and enable attributes as needed,
# have a look at +attr_accessible+.
def attr_protected(*attributes)
- write_inheritable_attribute("attr_protected", Set.new(attributes.map(&:to_s)) + (protected_attributes || []))
+ write_inheritable_attribute(:attr_protected, Set.new(attributes.map(&:to_s)) + (protected_attributes || []))
end
# Returns an array of all the attributes that have been protected from mass-assignment.
def protected_attributes # :nodoc:
- read_inheritable_attribute("attr_protected")
+ read_inheritable_attribute(:attr_protected)
end
# Specifies a white list of model attributes that can be set via
@@ -953,22 +953,22 @@ module ActiveRecord #:nodoc:
# customer.credit_rating = "Average"
# customer.credit_rating # => "Average"
def attr_accessible(*attributes)
- write_inheritable_attribute("attr_accessible", Set.new(attributes.map(&:to_s)) + (accessible_attributes || []))
+ write_inheritable_attribute(:attr_accessible, Set.new(attributes.map(&:to_s)) + (accessible_attributes || []))
end
# Returns an array of all the attributes that have been made accessible to mass-assignment.
def accessible_attributes # :nodoc:
- read_inheritable_attribute("attr_accessible")
+ read_inheritable_attribute(:attr_accessible)
end
# Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards.
def attr_readonly(*attributes)
- write_inheritable_attribute("attr_readonly", Set.new(attributes.map(&:to_s)) + (readonly_attributes || []))
+ write_inheritable_attribute(:attr_readonly, Set.new(attributes.map(&:to_s)) + (readonly_attributes || []))
end
# Returns an array of all the attributes that have been specified as readonly.
def readonly_attributes
- read_inheritable_attribute("attr_readonly")
+ read_inheritable_attribute(:attr_readonly)
end
# If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object,
@@ -992,7 +992,7 @@ module ActiveRecord #:nodoc:
# Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values.
def serialized_attributes
- read_inheritable_attribute("attr_serialized") or write_inheritable_attribute("attr_serialized", {})
+ read_inheritable_attribute(:attr_serialized) or write_inheritable_attribute(:attr_serialized, {})
end
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index da9f6d6893..749cc59284 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -283,13 +283,13 @@ module ActiveResource
format = mime_type_reference_or_format.is_a?(Symbol) ?
ActiveResource::Formats[mime_type_reference_or_format] : mime_type_reference_or_format
- write_inheritable_attribute("format", format)
+ write_inheritable_attribute(:format, format)
connection.format = format if site
end
# Returns the current format, default is ActiveResource::Formats::XmlFormat.
def format
- read_inheritable_attribute("format") || ActiveResource::Formats[:xml]
+ read_inheritable_attribute(:format) || ActiveResource::Formats[:xml]
end
# Sets the number of seconds after which requests to the REST API should time out.