class Myra::DnsRecord

Constants

MAP
PATH

Attributes

active[RW]
active?[RW]
alternative_cname[RW]
created[RW]
deleted[W]
id[R]
modified[RW]
name[RW]
ttl[RW]
type[RW]
value[RW]

Public Class Methods

from_hash(hash) click to toggle source
# 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
new(id: nil) click to toggle source
# 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

Public Instance Methods

deleted?() click to toggle source
# File lib/myra/objects/dns_record.rb, line 53
def deleted?
  @deleted
end
to_hash() click to toggle source
# File lib/myra/objects/dns_record.rb, line 48
def to_hash
  return new_record_hash if id.nil?
  record_hash
end

Private Instance Methods

new_record_hash() click to toggle source
# File lib/myra/objects/dns_record.rb, line 59
def new_record_hash
  Hash[MAP.map { |k, v| [k, send(v)] }].reject { |_, v| v.nil? }
end
record_hash() click to toggle source
# File lib/myra/objects/dns_record.rb, line 63
def record_hash
  hash = new_record_hash
  hash['id'] = id
  hash['modified'] = modified.to_s
  hash['created'] = created.to_s
  hash
end