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



8
9
10
# File 'lib/travis/client/singleton_setting.rb', line 8

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

Instance Method Details

#deleteObject



29
30
31
32
33
# File 'lib/travis/client/singleton_setting.rb', line 29

def delete
  session.delete_raw(path)
  reload
  true
end

#pathObject



18
19
20
# File 'lib/travis/client/singleton_setting.rb', line 18

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

#repository_idObject



14
15
16
# File 'lib/travis/client/singleton_setting.rb', line 14

def repository_id
  id
end

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



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

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