lib/gooddata/mixins/md_object_query.rb in gooddata-0.6.6 vs lib/gooddata/mixins/md_object_query.rb in gooddata-0.6.7

- old
+ new

@@ -22,11 +22,12 @@ # @param klass [Class] A class used for instantiating the returned data # @param options [Hash] the options hash # @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default # @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation def query(query_obj_type, klass, options = {}) - fail(NoProjectError, 'Connect to a project before searching for an object') unless GoodData.project - query_result = GoodData.get(GoodData.project.md['query'] + "/#{query_obj_type}/")['query']['entries'] + project = options[:project] || GoodData.project + fail(NoProjectError, 'Connect to a project before searching for an object') unless project + query_result = GoodData.get(project.md['query'] + "/#{query_obj_type}/")['query']['entries'] options[:full] ? query_result.map { |item| klass[item['link']] } : query_result end def dependency(uri, key = nil) result = GoodData.get(uri)['entries']