Skip to content

Commit

Permalink
extract formats_regexp as a method
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Oct 16, 2010
1 parent 15d3c77 commit 6c8ea83
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions actionpack/lib/action_view/renderer/abstract_renderer.rb
Expand Up @@ -16,15 +16,18 @@ def render
# 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={})
Expand Down

0 comments on commit 6c8ea83

Please sign in to comment.