Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove unnecessary attribute caching
  • Loading branch information
Jon Yurek committed Sep 14, 2012
1 parent dc3cbbd commit a16a50a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
4 changes: 0 additions & 4 deletions lib/paperclip/attachment.rb
Expand Up @@ -324,8 +324,6 @@ def instance_write(attr, value)
setter = :"#{name}_#{attr}="
if instance.respond_to?(setter)
instance.send(setter, value)
else
self.instance_variable_set("@_#{setter.to_s.chop}", value)
end
end

Expand All @@ -335,8 +333,6 @@ def instance_read(attr)
getter = :"#{name}_#{attr}"
if instance.respond_to?(getter)
instance.send(getter)
else
self.instance_variable_get("@_#{getter}")
end
end

Expand Down
10 changes: 1 addition & 9 deletions test/attachment_test.rb
Expand Up @@ -1083,16 +1083,8 @@ def do_after_all; end
assert_nothing_raised { @dummy.avatar = @file }
end

should "return the time when sent #avatar_updated_at" do
now = Time.now
Time.stubs(:now).returns(now)
should "not return the time when sent #avatar_updated_at" do
@dummy.avatar = @file
assert_equal now.to_i, @dummy.avatar.updated_at.to_i
end

should "return nil when reloaded and sent #avatar_updated_at" do
@dummy.save
@dummy.reload
assert_nil @dummy.avatar.updated_at
end

Expand Down

0 comments on commit a16a50a

Please sign in to comment.