Skip to content

Commit

Permalink
properly memoize {field_type,select_type} as class variable
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda authored and rafaelfranca committed Jan 23, 2012
1 parent bf5f483 commit fcfe1fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion actionpack/lib/action_view/helpers/tags/date_select.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ def render
error_wrapping(datetime_selector(@options, @html_options).send("select_#{select_type}").html_safe) error_wrapping(datetime_selector(@options, @html_options).send("select_#{select_type}").html_safe)
end end


class << self
def select_type
@select_type ||= self.name.split("::").last.sub("Select", "").downcase
end
end

private private


def select_type def select_type
self.class.name.split("::").last.sub("Select", "").downcase self.class.select_type
end end


def datetime_selector(options, html_options) def datetime_selector(options, html_options)
Expand Down
8 changes: 7 additions & 1 deletion actionpack/lib/action_view/helpers/tags/text_field.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ def render
tag("input", options) tag("input", options)
end end


class << self
def field_type
@field_type ||= self.name.split("::").last.sub("Field", "").downcase
end
end

private private


def field_type def field_type
@field_type ||= self.class.name.split("::").last.sub("Field", "").downcase self.class.field_type
end end
end end
end end
Expand Down

0 comments on commit fcfe1fa

Please sign in to comment.