Class: Myra::DnsRecord

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

Defined Under Namespace

Classes: Type

Constant Summary collapse

PATH =
'/dnsRecords'
MAP =
{
  # response field => target field
  'name' => 'name',
  'value' => 'value',
  'ttl' => 'ttl',
  'alternativeCname' => 'alternative_cname',
  'active' => 'active',
  'recordType' => 'type'
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil) ⇒ DnsRecord

Returns a new instance of DnsRecord.



29
30
31
32
33
34
35
# File 'lib/myra/objects/dns_record.rb', line 29

def initialize(id: nil)
  @id = id
  @active = true
  @type = Type::A
  @ttl = 300
  @deleted = false
end

Instance Attribute Details

#activeObject Also known as: active?

Returns the value of attribute active.



13
14
15
# File 'lib/myra/objects/dns_record.rb', line 13

def active
  @active
end

#alternative_cnameObject

Returns the value of attribute alternative_cname.



13
14
15
# File 'lib/myra/objects/dns_record.rb', line 13

def alternative_cname
  @alternative_cname
end

#createdObject

Returns the value of attribute created.



13
14
15
# File 'lib/myra/objects/dns_record.rb', line 13

def created
  @created
end

#deleted=(value) ⇒ Object (writeonly)

Sets the attribute deleted

Parameters:

  • value

    the value to set the attribute deleted to.



15
16
17
# File 'lib/myra/objects/dns_record.rb', line 15

def deleted=(value)
  @deleted = value
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/myra/objects/dns_record.rb', line 12

def id
  @id
end

#modifiedObject

Returns the value of attribute modified.



13
14
15
# File 'lib/myra/objects/dns_record.rb', line 13

def modified
  @modified
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/myra/objects/dns_record.rb', line 13

def name
  @name
end

#ttlObject

Returns the value of attribute ttl.



13
14
15
# File 'lib/myra/objects/dns_record.rb', line 13

def ttl
  @ttl
end

#typeObject

Returns the value of attribute type.



13
14
15
# File 'lib/myra/objects/dns_record.rb', line 13

def type
  @type
end

#valueObject

Returns the value of attribute value.



13
14
15
# File 'lib/myra/objects/dns_record.rb', line 13

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/myra/objects/dns_record.rb', line 37

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

Instance Method Details

#deleted?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/myra/objects/dns_record.rb', line 53

def deleted?
  @deleted
end

#to_hashObject



48
49
50
51
# File 'lib/myra/objects/dns_record.rb', line 48

def to_hash
  return new_record_hash if id.nil?
  record_hash
end