1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

extract formats_regexp as a method

This commit is contained in:
Santiago Pastorino 2010-10-16 14:12:41 -02:00
parent 15d3c77bc2
commit 6c8ea83385

View file

@ -16,15 +16,18 @@ module ActionView
# the lookup context to take this new format into account.
def wrap_formats(value)
return yield unless value.is_a?(String)
@@formats_regexp ||= /\.(#{Mime::SET.symbols.join('|')})$/
if value.sub!(@@formats_regexp, "")
if value.sub!(formats_regexp, "")
update_details(:formats => [$1.to_sym]){ yield }
else
yield
end
end
def formats_regexp
@@formats_regexp ||= /\.(#{Mime::SET.symbols.join('|')})$/
end
protected
def instrument(name, options={})