Class: Travis::Client::SingletonSetting

Inherits:
Entity
  • Object
show all
Defined in:
lib/travis/client/singleton_setting.rb

Direct Known Subclasses

SshKey

Constant Summary

Constants inherited from Entity

Entity::MAP

Instance Attribute Summary

Attributes inherited from Entity

#attributes, #curry, #id, #session

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#[], #[]=, aka, #attribute_names, attributes, #cancelable?, cast_id, #complete?, has, has_singleton, id?, id_field, #include?, #initialize, #inspect, inspect_info, #load, many, #missing?, one, preloadable, preloadable?, relations, #relations, #reload, #restartable?, subclass_for, subclasses, time, #to_h, #update_attributes, weak?

Constructor Details

This class inherits a constructor from Travis::Client::Entity

Class Method Details

.base_pathObject



6
7
8
# File 'lib/travis/client/singleton_setting.rb', line 6

def self.base_path
  "settings/#{one}"
end

Instance Method Details

#deleteObject



27
28
29
30
31
# File 'lib/travis/client/singleton_setting.rb', line 27

def delete
  session.delete_raw(path)
  reload
  true
end

#pathObject



16
17
18
# File 'lib/travis/client/singleton_setting.rb', line 16

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

#repository_idObject



12
13
14
# File 'lib/travis/client/singleton_setting.rb', line 12

def repository_id
  id
end

#update(values = {}) ⇒ Object Also known as: save



20
21
22
23
24
25
# File 'lib/travis/client/singleton_setting.rb', line 20

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