Commit 4dccd53a by Thijs Cadier Committed by Jon Yurek

Added support for :styles option being defined as a Proc.

(cherry picked from commit 5799558cb4211bed0fba67df36510a29cfbbd94c)
parent 3f5516ce
......@@ -32,6 +32,7 @@ module Paperclip
@path = options[:path]
@path = @path.call(self) if @path.is_a?(Proc)
@styles = options[:styles]
@styles = @styles.call(self) if @styles.is_a?(Proc)
@default_url = options[:default_url]
@validations = options[:validations]
@default_style = options[:default_style]
......
......@@ -217,6 +217,18 @@ class AttachmentTest < Test::Unit::TestCase
end
end
context "An attachment with :styles that is a proc" do
setup do
rebuild_model :styles => lambda{ |attachment| {:thumb => "50x50#", :large => "400x400"} }
@attachment = Dummy.new.avatar
end
should "have the correct geometry" do
assert_equal "50x50#", @attachment.styles[:thumb][:geometry]
end
end
context "An attachment with :url that is a proc" do
setup do
rebuild_model :url => lambda{ |attachment| "path/#{attachment.instance.other}.:extension" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment