Class: MailgunResource

Inherits:
ActiveResource::Base
  • Object
show all
Extended by:
Mailgun::RequestBuilder
Defined in:
lib/mailgun.rb

Overview

Base class for Mailgun resource classes It adds upsert() method on top of ActiveResource::Base

Direct Known Subclasses

Mailbox, Route

Instance Method Summary collapse

Methods included from Mailgun::RequestBuilder

prepare_request

Instance Method Details

#upsertObject

Create new resource or update it if resource already exist. There are 2 differences between upsert() and save():

 - Upsert does not raise an exception if a resource already exist.
 - Upsert does not return the id of freshly inserted resource

>> route = Route.new
>> route.pattern = '*@mydomain.com'
>> route.destination = 'http://mydomain.com/addcomment'
>> route.upsert()


128
129
130
# File 'lib/mailgun.rb', line 128

def upsert()
  self.class.post('upsert', {}, self.to_xml())
end