Sha256: 8f6e1ab7867a5dcc28d9216362b5a32a70680aa0aab0bab6b9b230c3c518f531

Contents?: true

Size: 926 Bytes

Versions: 2

Compression:

Stored size: 926 Bytes

Contents

module GoodData
  class ProjectMetadata

    class << self
      def [](key)
        if key == :all
          GoodData.get("/gdc/projects/#{GoodData.project.pid}/dataload/metadata")
        else 
          res = GoodData.get("/gdc/projects/#{GoodData.project.pid}/dataload/metadata/#{key}")
          res["metadataItem"]["value"]
        end
      end

      def has_key?(key)
        begin
          ProjectMetadata[key]
          true
        rescue RestClient::ResourceNotFound => e
          false
        end
      end

      def []=(key, val)
        data = {
          :metadataItem => {
           :key => key,
           :value => val
         }
        }
        uri = "/gdc/projects/#{GoodData.project.pid}/dataload/metadata/"
        update_uri = uri + key

        if has_key?(key)
          GoodData.put(update_uri, data)
        else
          GoodData.post(uri, data)
        end
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre6 lib/gooddata/models/project_metadata.rb
gooddata-0.6.0.pre5 lib/gooddata/models/project_metadata.rb