lib/gooddata/mixins/md_object_indexer.rb in gooddata-0.6.24 vs lib/gooddata/mixins/md_object_indexer.rb in gooddata-0.6.25
- old
+ new
@@ -14,19 +14,12 @@
# @param [Hash] options 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 [MdObject] if id is a String or number single object is returned
# @return [Array] if :all was provided as an id, list of objects should be returned. Note that this is implemented only in the subclasses. MdObject does not support this since API has no means to return list of all types of objects
def [](id, options = { :client => GoodData.connection, :project => GoodData.project })
- client = options[:client]
- fail ArgumentError, 'No :client specified' if client.nil?
+ client, project = GoodData.get_client_and_project(options)
- p = options[:project]
- fail ArgumentError, 'No :project specified' if p.nil?
-
- project = GoodData::Project[p, :client => client]
- fail ArgumentError, 'Wrong :project specified' if project.nil?
-
fail "You have to provide an \"id\" to be searched for." unless id
fail(NoProjectError, 'Connect to a project before searching for an object') unless project
return all(options) if id == :all
return id if id.is_a?(MdObject)
uri = if id.is_a?(Integer) || id =~ /^\d+$/
@@ -49,11 +42,15 @@
md_class = GoodData::Metric
when 'projectDashboard'
md_class = GoodData::Dashboard
when 'report'
md_class = GoodData::Report
+ when 'attributeDisplayForm'
+ md_class = GoodData::Label
when 'reportDefinition'
md_class = GoodData::ReportDefinition
+ when 'dataSet'
+ md_class = GoodData::Dataset
else
md_class = self
end
client.create(md_class, raw, client: client, project: project)