Sha256: 9ecfa0e9ebaf58a9780523bc6a0f2409c79426ed91a0dc1df64666ff172f68d2

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

# encoding: UTF-8

require_relative 'profile'

require_relative '../mixins/mixins'

module GoodData
  class ProjectRole
    attr_accessor :json

    include GoodData::Mixin::RestGetters

    class << self
      include GoodData::Mixin::RestResource
    end

    ProjectRole.root_key :projectRole

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

    def initialize(json)
      @json = json
    end

    ProjectRole.data_property_reader :permissions

    ProjectRole.metadata_property_reader :identifier, :title, :summary

    # Gets Users with this Role
    #
    # @return [Array<GoodData::Profile>] List of users
    def users
      res = []
      url = data['links']['roleUsers']
      tmp = GoodData.get url
      tmp['associatedUsers']['users'].each do |user_url|
        user = GoodData.get user_url
        res << GoodData::Profile.new(user)
      end
      res
    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

3 entries across 3 versions & 1 rubygems

Version Path
gooddata-0.6.7 lib/gooddata/models/project_role.rb
gooddata-0.6.6 lib/gooddata/models/project_role.rb
gooddata-0.6.5 lib/gooddata/models/project_role.rb