Sha256: 61ae884b670f598e5e92f99cdc7c97f3d88004a8b18642ab9b538b999ac3914c

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

# encoding: UTF-8

require 'pmap'

require_relative 'profile'

require_relative '../rest/rest'

require_relative '../mixins/rest_resource'

module GoodData
  class ProjectRole < GoodData::Rest::Object
    attr_accessor :json

    include GoodData::Mixin::RestResource

    root_key :projectRole

    include GoodData::Mixin::Author
    include GoodData::Mixin::Contributor
    include GoodData::Mixin::Timestamps

    def initialize(json)
      @json = json
    end

    data_property_reader :permissions

    metadata_property_reader :identifier, :title, :summary

    # Gets Users with this Role
    #
    # @return [Array<GoodData::Profile>] List of users
    def users
      url = data['links']['roleUsers']
      tmp = client.get url
      tmp['associatedUsers']['users'].pmap do |user_url|
        url = user_url
        user = client.get url
        client.create(GoodData::Profile, user)
      end
    end

    # Gets Raw object URI
    #
    # @return [string] URI of this project role
    def uri
      @json['projectRole']['links']['roleUsers'].split('/')[0...-1].join('/')
    end

    def ==(other)
      uri == other.uri
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gooddata-0.6.15 lib/gooddata/models/project_role.rb
gooddata-0.6.14 lib/gooddata/models/project_role.rb
gooddata-0.6.13 lib/gooddata/models/project_role.rb
gooddata-0.6.12 lib/gooddata/models/project_role.rb
gooddata-0.6.11 lib/gooddata/models/project_role.rb
gooddata-0.6.10 lib/gooddata/models/project_role.rb
gooddata-0.6.9 lib/gooddata/models/project_role.rb
gooddata-0.6.8 lib/gooddata/models/project_role.rb