Skip to content

Commit

Permalink
Refactor File#== to avoid an unnecessary API call
Browse files Browse the repository at this point in the history
The new_record? call used to cause an API call to fedora, which we are
now able to avoid.
  • Loading branch information
jcoyne committed Jun 29, 2015
1 parent 5106c86 commit d61986c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/active_fedora/file.rb
Expand Up @@ -51,8 +51,10 @@ def initialize(parent_or_url_or_hash = nil, path=nil, options={})
end

def ==(comparison_object)
return true if comparison_object.equal?(self)
comparison_object.instance_of?(self.class) && comparison_object.uri == uri && !comparison_object.new_record?
super ||
comparison_object.instance_of?(self.class) &&
id.present? &&
comparison_object.uri == uri
end

def ldp_source
Expand Down

0 comments on commit d61986c

Please sign in to comment.