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:
parent
15d3c77bc2
commit
6c8ea83385
1 changed files with 5 additions and 2 deletions
|
@ -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={})
|
||||
|
|
Loading…
Reference in a new issue