lib/gooddata/helpers/global_helpers.rb
def prepare_mapping(what, for_what = nil, options = {})
        project = options[:project] || (for_what.is_a?(Hash) && for_what[:project]) || fail('Project has to be provided')
        mapping = if what.is_a?(Hash)
                    whats = what.keys
                    to_whats = what.values
                    whats.zip(to_whats)
                  elsif what.is_a?(Array) && for_what.is_a?(Array)
                    whats.zip(to_whats)
                  else
                    [[what, for_what]]
                  end
        mapping.pmap { |f, t| [project.objects(f), project.objects(t)] }
      end
# It takes what should be mapped to what and creates a mapping that is suitable for other internal methods.
# This means looking up the objects and returning it as array of pairs.
# The input can be given in several ways
#
# 1. Hash. For example it could look like
# {'label.states.name' => 'label.state.id'}
#
# 2 Arrays. In such case the arrays are zipped together. First item will be swapped for the first item in the second array etc.
# ['label.states.name'], ['label.state.id']
#
# @param what [Hash | Array] List/Hash of objects to be swapped
# @param for_what [Array] List of objects to be swapped
# @return [Array<GoodData::MdObject>] List of pairs of objects
It takes what should be mapped to what and creates a mapping that is suitable for other internal methods.
This means looking up the objects and returning it as array of pairs.
The input can be given in several ways

1. Hash.

2 Arrays. In such case the arrays are zipped together. First item will be swapped for the first item in the second array etc.
It takes what should be mapped to what and creates a mapping that is suitable for other internal methods . This means looking up the objects and returning it as array of pairs . The input can be given in several ways 1 . Hash . 2 Arrays . In such case the arrays are zipped together . First item will be swapped for the first item in the second array etc .
def prepare_mapping(what, for_what = nil, options = {})
        project = options[:project] || (for_what.is_a?(Hash) && for_what[:project]) || fail('Project has to be provided')
        mapping = if what.is_a?(Hash)
                    whats = what.keys
                    to_whats = what.values
                    whats.zip(to_whats)
                  elsif what.is_a?(Array) && for_what.is_a?(Array)
                    whats.zip(to_whats)
                  else
                    [[what, for_what]]
                  end
        mapping.pmap { |f, t| [project.objects(f), project.objects(t)] }
      end
def prepare_mapping ( what , for_what = nil , options = { } ) project = options [ :project ] || ( for_what . is_a? ( Hash ) && for_what [ :project ] ) || fail ( 'Project has to be provided' ) mapping = if what . is_a? ( Hash ) whats = what . keys to_whats = what . values whats . zip ( to_whats ) elsif what . is_a? ( Array ) && for_what . is_a? ( Array ) whats . zip ( to_whats ) else [ [ what , for_what ] ] end mapping . pmap { | f , t | [ project . objects ( f ) , project . objects ( t ) ] } end
It takes what should be mapped to what and creates a mapping that is suitable for other internal methods.
It takes what should be mapped to what and creates a mapping that is suitable for other internal methods .
List of pairs of objects
List of pairs of objects
Array<GoodData::MdObject>
what
List/Hash of objects to be swapped
List / Hash of objects to be swapped
for_what
List of objects to be swapped
List of objects to be swapped
options