Skip to content

Commit

Permalink
deprecate the find method in favor of get method for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Dec 18, 2023
1 parent fe41668 commit ab9048e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/ontologies_api_client/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ def where(params = {}, &block)

##
# Find a resource by id
# @deprecated replace with "get"
def find(id, params = {})
found = where do |obj|
obj.id.eql?(id)
end
found.first
[get(id, params)]
end

##
# Get a resource by id (this will retrieve it from the REST service)
def get(id, params = {})
path = collection_path
id = "#{path}/#{id}" unless id.include?(path)
HTTP.get(id, params)
end

Expand Down
5 changes: 4 additions & 1 deletion lib/ontologies_api_client/models/ontology.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def self.find_by(attrs, *args)
# Override to search for views as well by default
# Views get hidden on the REST service unless the `include_views`
# parameter is set to `true`
def find(id, params = {})
def self.find(id, params = {})
params[:include_views] = params[:include_views] || true
super(id, params)
end
Expand All @@ -119,6 +119,9 @@ def self.include_params
"acronym,administeredBy,group,hasDomain,name,notes,projects,reviews,summaryOnly,viewingRestriction"
end

def self.find_by_acronym(acronym, params = {})
[find(acronym, params)]
end
end
end
end
Expand Down

0 comments on commit ab9048e

Please sign in to comment.