Sha256: d7a71abdb865635a749d9d75cc1cdc3795f6d05d20ebf0b0b296ed0613d27c62

Contents?: true

Size: 705 Bytes

Versions: 6

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

require 'json'

module Travis
  module Client
    class SingletonSetting < Entity
      def self.base_path
        "settings/#{one}"
      end

      has :repository

      def repository_id
        id
      end

      def path
        "#{self.class.base_path}/#{id}"
      end

      def update(values = {})
        values = { 'value' => values } unless values.is_a? Hash
        values.each { |key, value| attributes[key.to_s] = value.to_s }
        session.patch_raw(path, JSON.dump(self.class.one => attributes))
        reload
      end

      def delete
        session.delete_raw(path)
        reload
        true
      end

      alias save update
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
travis-1.14.0 lib/travis/client/singleton_setting.rb
travis-1.13.3 lib/travis/client/singleton_setting.rb
travis-1.13.2 lib/travis/client/singleton_setting.rb
travis-1.13.1 lib/travis/client/singleton_setting.rb
travis-1.13.0 lib/travis/client/singleton_setting.rb
travis-1.12.0 lib/travis/client/singleton_setting.rb