diff --git a/lib/ontologies_api_client/collection.rb b/lib/ontologies_api_client/collection.rb index 7e6b476..6e0e36f 100644 --- a/lib/ontologies_api_client/collection.rb +++ b/lib/ontologies_api_client/collection.rb @@ -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 diff --git a/lib/ontologies_api_client/models/ontology.rb b/lib/ontologies_api_client/models/ontology.rb index 5db6ed4..0aeb365 100644 --- a/lib/ontologies_api_client/models/ontology.rb +++ b/lib/ontologies_api_client/models/ontology.rb @@ -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 @@ -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