Class: Gandi::Domain::Forward
- Inherits:
-
Object
- Object
- Gandi::Domain::Forward
- Includes:
- GandiObjectMethods
- Defined in:
- lib/gandi/domain/forward.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
-
.count(domain, opts = {}) ⇒ Object
Count forwards for a domain.
-
.create(domain, source, params) ⇒ Object
Create a new forward.
-
.list(domain, opts = {}) ⇒ Object
List forwards for specified domain.
Instance Method Summary collapse
-
#delete ⇒ Object
Delete a forward.
-
#destinations ⇒ Object
Return the destinations emails for this forward.
-
#initialize(domain, source, attributes = nil) ⇒ Forward
constructor
A new instance of Forward.
-
#update(params) ⇒ Object
Update a forward.
Methods included from GandiObjectMethods
#[], included, #inspect, #to_hash
Constructor Details
#initialize(domain, source, attributes = nil) ⇒ Forward
Returns a new instance of Forward.
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
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
6 7 8 |
# File 'lib/gandi/domain/forward.rb', line 6 def domain @domain end |
#source ⇒ Object (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
#delete ⇒ Object
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 |
#destinations ⇒ Object
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 |