Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
From 52c78f9649e6d06d591fa1b5f52187580999f0fa Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Mislav=20Marohni=C4=87?= <mislav.marohnic@gmail.com> Date: Sat, 19 Apr 2008 22:04:25 +0200 Subject: [PATCH] Remove default_style from Attachment#interpolate. Fix incorrect doc at Attachment#valid? --- lib/paperclip.rb | 14 +++++++------- lib/paperclip/attachment.rb | 15 +++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/paperclip.rb b/lib/paperclip.rb index 95ba3ce..a368fc0 100644 --- a/lib/paperclip.rb +++ b/lib/paperclip.rb @@ -80,14 +80,14 @@ module Paperclip # that can control permissions. You can specify the full domain and path, but usually # just an absolute path is sufficient. The leading slash must be included manually for # absolute paths. The default value is "/:class/:attachment/:id/:style_:filename". See - # Paperclip::Attachment#interpolate for more information on variable interpolaton. - # :url => "/:attachment/:id/:style_:basename:extension" - # :url => "http://some.other.host/stuff/:class/:id_:extension" + # Paperclip::Attachment.interpolations for more information on variable interpolaton. + # :url => "/:attachment/:id/:style-:basename:extension" + # :url => "http://some.other.host/stuff/:class/:id-:extension" # * +default_url+: The URL that will be returned if there is no attachment assigned. # This field is interpolated just as the url is. The default value is # "/:class/:attachment/missing_:style.png" - # has_attached_file :avatar, :default_url => "/images/default_:style_avatar.png" - # User.new.avatar_url(:small) # => "/images/default_small_avatar.png" + # has_attached_file :avatar, :default_url => "/images/default-:style-avatar.png" + # User.new.avatar_url(:small) # => "/images/default-small-avatar.png" # * +styles+: A hash of thumbnail styles and their geometries. You can find more about # geometry strings at the ImageMagick website # (http://www.imagemagick.org/script/command-line-options.php#resize). Paperclip @@ -102,12 +102,12 @@ module Paperclip # * +path+: The location of the repository of attachments on disk. This can be coordinated # with the value of the +url+ option to allow files to be saved into a place where Apache # can serve them without hitting your app. Defaults to - # ":rails_root/public/:class/:attachment/:id/:style_:filename". + # ":rails_root/public/:attachment/:id/:style/:basename.:extension". # By default this places the files in the app's public directory which can be served # directly. If you are using capistrano for deployment, a good idea would be to # make a symlink to the capistrano-created system directory from inside your app's # public directory. - # See Paperclip::Attachment#interpolate for more information on variable interpolaton. + # See Paperclip::Attachment.interpolations for more information on variable interpolaton. # :path => "/var/app/attachments/:class/:id/:style/:filename" # * +whiny_thumbnails+: Will raise an error if Paperclip cannot process thumbnails of an # uploaded image. This will ovrride the global setting for this attachment. diff --git a/lib/paperclip/attachment.rb b/lib/paperclip/attachment.rb index 3b400a7..c623d03 100644 --- a/lib/paperclip/attachment.rb +++ b/lib/paperclip/attachment.rb @@ -96,9 +96,9 @@ module Paperclip url(style) end - # Returns true if there are any errors on this attachment. + # Returns false if there are errors on this attachment. def valid? - errors.length == 0 + errors.empty? end # Returns an array containing the errors on this attachment. @@ -214,14 +214,13 @@ module Paperclip end def interpolate pattern, style = nil #:nodoc: - style ||= default_style - pattern = pattern.dup - self.class.interpolations.each do |tag, l| - pattern.gsub!(/:\b#{tag}\b/) do |match| - l.call( self, style ) + result = pattern.dup + self.class.interpolations.each do |name, replace| + result.gsub!(/:#{name}\b/) do |match| + replace.call(self, style) end end - pattern + result end def queue_existing_for_delete #:nodoc: -- 1.5.3.5
From the Design Piracy series on my blog: