Class: Ey::Core::Client::AddonAttachment

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/vendor/core/ey-core/models/addon_attachment.rb

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #update!, #url

Instance Method Details

#attach!(key) ⇒ Object



15
16
17
18
# File 'lib/vendor/core/ey-core/models/addon_attachment.rb', line 15

def attach!(key)
  self.key = key
  self.save!
end

#detach!Object



20
21
22
23
# File 'lib/vendor/core/ey-core/models/addon_attachment.rb', line 20

def detach!
  self.key = nil
  self.save!
end

#resource_urlObject



11
12
13
# File 'lib/vendor/core/ey-core/models/addon_attachment.rb', line 11

def resource_url
  "#{collection.url}/#{id}"
end

#save!Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/vendor/core/ey-core/models/addon_attachment.rb', line 25

def save!
  # always update
  params = {
    "attachment" => {
      "key" => self.key,
    },
    "url" => self.resource_url,
  }
  merge_attributes(self.connection.update_addon_attachment(params).body["addon_attachment"])
end