Permalink
Browse files

Lazy generate variant parser so new transformations can be added

after image server is required
  • Loading branch information...
1 parent 2f3866f commit 8b934022e10313dfa4295854190d62f2b0b6a0b1 @josh josh committed with Dec 16, 2009
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/image_variant_generator.rb
@@ -4,13 +4,16 @@
class ImageVariantGenerator
VARIANT_DELIMITER = '_'
SupportedImageTypes = ['.gif', '.jpg', '.jpeg', '.png', '.bmp']
- VariantParser = /(.*)\_(#{Transformations.list.join('|')})(#{SupportedImageTypes.join('|')})/i
attr_accessor :content
attr_accessor :content_type
-
+
+ def self.variant_parser
+ @variant_parser ||= /(.*)\_(#{Transformations.list.join('|')})(#{SupportedImageTypes.join('|')})/i
+ end
+
def self.from_url(server, path)
- return nil unless path =~ VariantParser
+ return nil unless path =~ variant_parser
remote_path = "#{$1}#{$3}"

0 comments on commit 8b93402

Please sign in to comment.