aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorabhishek <abhishek.jain@vinsol.com>2013-12-18 16:17:11 +0530
committerabhishek <abhishek.jain@vinsol.com>2013-12-18 16:17:11 +0530
commit21f0c580f3fddc56e0e7313780ee5dd95f3edb11 (patch)
treeb74b3b93111ee04da7d4023a7303c131283205fb /actionview
parent2c9cb495f379856704b3f23da71fb60bc5a332d5 (diff)
downloadrails-21f0c580f3fddc56e0e7313780ee5dd95f3edb11.tar.gz
rails-21f0c580f3fddc56e0e7313780ee5dd95f3edb11.tar.bz2
rails-21f0c580f3fddc56e0e7313780ee5dd95f3edb11.zip
duplication removed(DRY)
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/helpers/asset_tag_helper.rb26
1 files changed, 10 insertions, 16 deletions
diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb
index bc5007b11d..ea1aadcc43 100644
--- a/actionview/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb
@@ -207,14 +207,7 @@ module ActionView
options[:alt] = options.fetch(:alt){ image_alt(src) }
end
- if size = options.delete(:size)
- if size =~ %r{\A\d+x\d+\z}
- options[:width], options[:height] = size.split('x')
- elsif size =~ %r{\A\d+\z}
- options[:width] = options[:height] = size
- end
- end
-
+ options[:width], options[:height] = extract_dimensions(options.delete(:size)) if options[:size]
tag("img", options)
end
@@ -280,14 +273,7 @@ module ActionView
def video_tag(*sources)
multiple_sources_tag('video', sources) do |options|
options[:poster] = path_to_image(options[:poster]) if options[:poster]
-
- if size = options.delete(:size)
- if size =~ %r{\A\d+x\d+\z}
- options[:width], options[:height] = size.split('x')
- elsif size =~ %r{\A\d+\z}
- options[:width] = options[:height] = size
- end
- end
+ options[:width], options[:height] = extract_dimensions(options.delete(:size)) if options[:size]
end
end
@@ -323,6 +309,14 @@ module ActionView
content_tag(type, nil, options)
end
end
+
+ def extract_dimensions(size)
+ if size =~ %r{\A\d+x\d+\z}
+ size.split('x')
+ elsif size =~ %r{\A\d+\z}
+ [size, size]
+ end
+ end
end
end
end