class Myra::Domain
Constants
- MAP
- PATH
Attributes
auto_dns[RW]
auto_update[RW]
created[RW]
id[R]
maintenance[RW]
modified[RW]
name[RW]
owned[RW]
paused[RW]
paused_until[RW]
reversed[RW]
Public Class Methods
from_hash(hash)
click to toggle source
# 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
new(id: nil)
click to toggle source
# 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
Public Instance Methods
to_hash()
click to toggle source
# File lib/myra/objects/domain.rb, line 44 def to_hash return new_domain_hash if id.nil? domain_hash end
Private Instance Methods
domain_hash()
click to toggle source
# File lib/myra/objects/domain.rb, line 55 def domain_hash hash = new_domain_hash hash['id'] = id hash['modified'] = modified.to_s hash['created'] = created.to_s hash end
new_domain_hash()
click to toggle source
# File lib/myra/objects/domain.rb, line 51 def new_domain_hash Hash[MAP.map { |k, v| [k, send(v)] }] end