Class: Gandi::Domain::Forward

Inherits:
Object
  • Object
show all
Includes:
GandiObjectMethods
Defined in:
lib/gandi/domain/forward.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GandiObjectMethods

#[], included, #inspect, #to_hash

Constructor Details

#initialize(domain, source, attributes = nil) ⇒ Forward

Returns a new instance of Forward.

Raises:



8
9
10
11
12
13
# File 'lib/gandi/domain/forward.rb', line 8

def initialize(domain, source, attributes = nil)
  @domain = domain
  @source = source
  @attributes = attributes || self.class.call('domain.forward.list', @domain.fqdn, {'source' => @source}).first
  raise DataError, "Forward does not exist" unless @attributes
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



6
7
8
# File 'lib/gandi/domain/forward.rb', line 6

def domain
  @domain
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/gandi/domain/forward.rb', line 6

def source
  @source
end

Class Method Details

.count(domain, opts = {}) ⇒ Object

Count forwards for a domain. TODO: accept a fqdn string.



43
44
45
# File 'lib/gandi/domain/forward.rb', line 43

def count(domain, opts = {})
  call('domain.forward.count', domain.fqdn, opts)
end

.create(domain, source, params) ⇒ Object

Create a new forward. Return a Forward object.



36
37
38
39
# File 'lib/gandi/domain/forward.rb', line 36

def create(domain, source, params)
  forward = call('domain.forward.create', domain.fqdn, source, params)
  self.new(domain, source, forward)
end

.list(domain, opts = {}) ⇒ Object

List forwards for specified domain. Return an array of Forward objects. TODO: accept a fqdn string.



50
51
52
53
54
# File 'lib/gandi/domain/forward.rb', line 50

def list(domain, opts = {})
  call('domain.forward.list', domain.fqdn, opts).map do |forward|
    self.new(domain, forward['source'], forward)
  end
end

Instance Method Details

#deleteObject

Delete a forward. Return true.



22
23
24
# File 'lib/gandi/domain/forward.rb', line 22

def delete
  self.class.call('domain.forward.delete', @domain.fqdn, @source)
end

#destinationsObject

Return the destinations emails for this forward.



16
17
18
# File 'lib/gandi/domain/forward.rb', line 16

def destinations
  @attributes['destinations']
end

#update(params) ⇒ Object

Update a forward. Return self.



28
29
30
31
# File 'lib/gandi/domain/forward.rb', line 28

def update(params)
  @attributes = self.class.call('domain.forward.update', @domain.fqdn, @source, params)
  return self
end