Class: Myra::Domain

Inherits:
Object
  • Object
show all
Defined in:
lib/myra/objects/domain.rb

Constant Summary collapse

PATH =
'/domains'
MAP =
{
  # response field => target field
  'name' => 'name',
  'autoUpdate' => 'auto_update',
  'maintenance' => 'maintenance',
  'owned' => 'owned',
  'reversed' => 'reversed',
  'paused' => 'paused',
  'autoDns' => 'auto_dns'
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil) ⇒ Domain

Returns a new instance of Domain.



26
27
28
29
30
31
# File 'lib/myra/objects/domain.rb', line 26

def initialize(id: nil)
  @id = id
  %w(maintenance auto_update auto_dns paused owned reversed).each do |field|
    send("#{field}=", false)
  end
end

Instance Attribute Details

#auto_dnsObject

Returns the value of attribute auto_dns.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def auto_dns
  @auto_dns
end

#auto_updateObject

Returns the value of attribute auto_update.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def auto_update
  @auto_update
end

#createdObject

Returns the value of attribute created.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def created
  @created
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/myra/objects/domain.rb', line 7

def id
  @id
end

#maintenanceObject

Returns the value of attribute maintenance.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def maintenance
  @maintenance
end

#modifiedObject

Returns the value of attribute modified.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def modified
  @modified
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def name
  @name
end

#ownedObject

Returns the value of attribute owned.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def owned
  @owned
end

#pausedObject

Returns the value of attribute paused.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def paused
  @paused
end

#paused_untilObject

Returns the value of attribute paused_until.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def paused_until
  @paused_until
end

#reversedObject

Returns the value of attribute reversed.



8
9
10
# File 'lib/myra/objects/domain.rb', line 8

def reversed
  @reversed
end

Class Method Details

.from_hash(hash) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/myra/objects/domain.rb', line 33

def self.from_hash(hash)
  domain = new(id: hash['id'])
  %w(modified created).each do |date_field|
    domain.send "#{date_field}=", DateTime.parse(hash[date_field])
  end
  MAP.each do |k, v|
    domain.send "#{v}=", hash[k] if hash.key?(k)
  end
  domain
end

Instance Method Details

#to_hashObject



44
45
46
47
# File 'lib/myra/objects/domain.rb', line 44

def to_hash
  return new_domain_hash if id.nil?
  domain_hash
end