Module: GoodData::Mixin::MdFinders
- Included in:
- GoodData::MdObject
- Defined in:
- lib/gooddata/mixins/md_finders.rb
Instance Method Summary collapse
-
#find_by_identifier(identifier, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject>
Finds a specific type of the object by identifier.
- #find_by_tag(tags, opts = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Object
-
#find_by_title(title, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject>
Finds a specific type of the object by title.
-
#find_first_by_identifier(identifier, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject>
Finds a specific type of the object by identifier.
-
#find_first_by_title(title, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject>
Finds a specific type of the object by title.
Instance Method Details
#find_by_identifier(identifier, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject>
Finds a specific type of the object by identifier. Returns all matches. Returns full object.
30 31 32 33 34 35 36 37 38 |
# File 'lib/gooddata/mixins/md_finders.rb', line 30 def find_by_identifier(identifier, = { :client => GoodData.connection, :project => GoodData.project }) all = self[:all, ] items = if identifier.is_a?(Regexp) all.select { |r| r.title =~ identifier } else all.select { |r| r.title == identifier } end items.pmap { |item| self[item.uri, ] unless item.nil? } end |
#find_by_tag(tags, opts = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/gooddata/mixins/md_finders.rb', line 40 def find_by_tag(, opts = { :client => GoodData.connection, :project => GoodData.project }) client, project = GoodData.get_client_and_project(opts) = .split(',').map(&:strip) unless .is_a?(Array) self[:all, client: client, project: project] .select { |r| (r.tag_set & ).any? } end |
#find_by_title(title, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject>
Finds a specific type of the object by title. Returns all matches. Returns full object.
68 69 70 71 72 73 74 75 76 |
# File 'lib/gooddata/mixins/md_finders.rb', line 68 def find_by_title(title, = { :client => GoodData.connection, :project => GoodData.project }) all = self[:all, ] items = if title.is_a?(Regexp) all.select { |r| r.title =~ title } else all.select { |r| r.title == title } end items.pmap { |item| self[item.uri, ] unless item.nil? } end |
#find_first_by_identifier(identifier, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject>
Finds a specific type of the object by identifier. Returns first match. Returns full object.
15 16 17 18 19 20 21 22 23 |
# File 'lib/gooddata/mixins/md_finders.rb', line 15 def find_first_by_identifier(identifier, = { :client => GoodData.connection, :project => GoodData.project }) all = self[:all, .merge(full: false)] item = if identifier.is_a?(Regexp) all.find { |r| r.identifier =~ identifier } else all.find { |r| r.identifier == identifier } end self[item.uri, ] unless item.nil? end |
#find_first_by_title(title, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject>
Finds a specific type of the object by title. Returns first match. Returns full object.
53 54 55 56 57 58 59 60 61 |
# File 'lib/gooddata/mixins/md_finders.rb', line 53 def find_first_by_title(title, = { :client => GoodData.connection, :project => GoodData.project }) all = self[:all, ] item = if title.is_a?(Regexp) all.find { |r| r.title =~ title } else all.find { |r| r.title == title } end self[item.uri, ] unless item.nil? end |