Skip to content

Commit

Permalink
Merge pull request #150 from projecthydra/cleaning-up-af-base-exists
Browse files Browse the repository at this point in the history
Tidying up how ActiveFedora::Base.exists? behaves
  • Loading branch information
jcoyne committed Jul 11, 2013
2 parents 7f55fc2 + 71c96cd commit fa65b04
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/active_fedora/querying.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ def find_each( conditions={}, opts={})
end


# Returns true if the pid exists in the repository
# @param[String] pid
# @return[boolean]
# Returns true if the pid exists in the repository
# @param[String] pid
# @return[boolean]
def exists?(pid)
return false if pid.nil? || pid.empty?
inner = DigitalObject.find_or_initialize(self, pid)
!inner.new?
!!DigitalObject.find(self, pid)
rescue ActiveFedora::ObjectNotFoundError
false
end

# Returns a solr result matching the supplied conditions
Expand Down

0 comments on commit fa65b04

Please sign in to comment.