Class: Ey::Core::Client::Connector

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/vendor/core/ey-core/models/connector.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

#save!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vendor/core/ey-core/models/connector.rb', line 12

def save!
  requires :source, :destination

  params = {
    "url"       => self.collection.url,
    "connector" => {
      "source"        => source.identity,
      "destination"   => destination.identity,
      "configuration" => configuration,
    },
  }

  response = if new_record?
               self.connection.create_connector(params)
             else
               requires :identity

               self.connection.update_connector(params.merge("id" => self.identity))
             end

  merge_attributes(response.body["connector"])
end