Class: SemaphoreClient::Model::ConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/semaphore_client/model/config_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/semaphore_client/model/config_file.rb', line 5

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



4
5
6
# File 'lib/semaphore_client/model/config_file.rb', line 4

def created_at
  @created_at
end

#encryptedObject (readonly)

Returns the value of attribute encrypted.



4
5
6
# File 'lib/semaphore_client/model/config_file.rb', line 4

def encrypted
  @encrypted
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/semaphore_client/model/config_file.rb', line 4

def id
  @id
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/semaphore_client/model/config_file.rb', line 5

def path
  @path
end

#sharedObject (readonly)

Returns the value of attribute shared.



4
5
6
# File 'lib/semaphore_client/model/config_file.rb', line 4

def shared
  @shared
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



4
5
6
# File 'lib/semaphore_client/model/config_file.rb', line 4

def updated_at
  @updated_at
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/semaphore_client/model/config_file.rb', line 4

def url
  @url
end

Class Method Details

.create(attributes) ⇒ Object



11
12
13
# File 'lib/semaphore_client/model/config_file.rb', line 11

def self.create(attributes)
  new.update(attributes)
end

.load(attributes) ⇒ Object



7
8
9
# File 'lib/semaphore_client/model/config_file.rb', line 7

def self.load(attributes)
  new.load(attributes)
end

Instance Method Details

#load(attributes) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/semaphore_client/model/config_file.rb', line 15

def load(attributes)
  attributes = symbolize_keys(attributes)

  @id = attributes[:id] if attributes.key?(:id)
  @path = attributes[:path] if attributes.key?(:path)
  @url = attributes[:url] if attributes.key?(:url)
  @content = attributes[:content] if attributes.key?(:content)
  @shared = attributes[:shared] if attributes.key?(:shared)
  @encrypted = attributes[:encrypted] if attributes.key?(:encrypted)
  @created_at = attributes[:created_at] if attributes.key?(:created_at)
  @updated_at = attributes[:updated_at] if attributes.key?(:updated_at)

  self
end

#serializeObject



45
46
47
48
49
50
51
52
# File 'lib/semaphore_client/model/config_file.rb', line 45

def serialize
  object_hash = {
    "path" => @path,
    "content" => @content,
  }

  object_hash.delete_if { |_, value| value.nil? }
end

#update(attributes) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/semaphore_client/model/config_file.rb', line 30

def update(attributes)
  attributes = symbolize_keys(attributes)

  updatable_keys = [:path, :content]

  if (attributes.keys - updatable_keys).any?
    raise SemaphoreClient::Exceptions::AttributeNotAvailable
  end

  @path = attributes[:path] if attributes.key?(:path)
  @content = attributes[:content] if attributes.key?(:content)

  self
end