Commit 232cacb7 by George Brocklehurst Committed by Mike Burns

Remove redundant Hash subclass.

parent 9e9674af
...@@ -40,7 +40,6 @@ require 'paperclip/interpolations' ...@@ -40,7 +40,6 @@ require 'paperclip/interpolations'
require 'paperclip/tempfile_factory' require 'paperclip/tempfile_factory'
require 'paperclip/style' require 'paperclip/style'
require 'paperclip/attachment' require 'paperclip/attachment'
require 'paperclip/attachment_options'
require 'paperclip/storage' require 'paperclip/storage'
require 'paperclip/callbacks' require 'paperclip/callbacks'
require 'paperclip/file_command_content_type_detector' require 'paperclip/file_command_content_type_detector'
...@@ -176,8 +175,6 @@ module Paperclip ...@@ -176,8 +175,6 @@ module Paperclip
def has_attached_file(name, options = {}) def has_attached_file(name, options = {})
HasAttachedFile.define_on(self, name, options) HasAttachedFile.define_on(self, name, options)
options = Paperclip::AttachmentOptions.new(options)
Paperclip::Tasks::Attachments.add(self, name, options) Paperclip::Tasks::Attachments.add(self, name, options)
after_save { send(name).send(:save) } after_save { send(name).send(:save) }
......
module Paperclip
class AttachmentOptions < Hash
def initialize(options)
options.each do |k, v|
self.[]=(k, v)
end
end
end
end
require './test/helper'
class AttachmentOptionsTest < Test::Unit::TestCase
should "be a Hash" do
assert_kind_of Hash, Paperclip::AttachmentOptions.new({})
end
should "respond to []" do
assert Paperclip::AttachmentOptions.new({}).respond_to?(:[])
end
should "deliver the specified options through []" do
intended_options = {:specific_key => "specific value"}
attachment_options = Paperclip::AttachmentOptions.new(intended_options)
assert_equal "specific value", attachment_options[:specific_key]
end
should "respond to []=" do
assert Paperclip::AttachmentOptions.new({}).respond_to?(:[]=)
end
should "remember options set with []=" do
attachment_options = Paperclip::AttachmentOptions.new({})
attachment_options[:foo] = "bar"
assert_equal "bar", attachment_options[:foo]
end
end
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