Browse files

properly memoize {field_type,select_type} as class variable

  • Loading branch information...
1 parent bf5f483 commit fcfe1fa87813bf85697c7a0db519e8ed9a483fc6 @amatsuda amatsuda committed with Jan 18, 2012
View
8 actionpack/lib/action_view/helpers/tags/date_select.rb
@@ -12,10 +12,16 @@ def render
error_wrapping(datetime_selector(@options, @html_options).send("select_#{select_type}").html_safe)
end
+ class << self
+ def select_type
+ @select_type ||= self.name.split("::").last.sub("Select", "").downcase
+ end
+ end
+
private
def select_type
- self.class.name.split("::").last.sub("Select", "").downcase
+ self.class.select_type
end
def datetime_selector(options, html_options)
View
8 actionpack/lib/action_view/helpers/tags/text_field.rb
@@ -13,10 +13,16 @@ def render
tag("input", options)
end
+ class << self
+ def field_type
+ @field_type ||= self.name.split("::").last.sub("Field", "").downcase
+ end
+ end
+
private
def field_type
- @field_type ||= self.class.name.split("::").last.sub("Field", "").downcase
+ self.class.field_type
end
end
end

0 comments on commit fcfe1fa

Please sign in to comment.