class Moniker::Record

A Moniker Domain

Attributes

Public Class Methods

find_all_by_data(data, options = {}) click to toggle source
# File lib/moniker/record.rb, line 118
def self.find_all_by_data(data, options = {})
  all(options).select { |record| record.data == data }
end
find_all_by_name(name, options = {}) click to toggle source
# File lib/moniker/record.rb, line 110
def self.find_all_by_name(name, options = {})
  all(options).select { |record| record.name == name }
end
find_all_by_type(type, options = {}) click to toggle source
# File lib/moniker/record.rb, line 114
def self.find_all_by_type(type, options = {})
  all(options).select { |record| record.type == type }
end
find_by_name(name, options = {}) click to toggle source
# File lib/moniker/record.rb, line 106
def self.find_by_name(name, options = {})
  all(options).detect { |record| record.name == name }
end

Public Instance Methods

domain() click to toggle source
# File lib/moniker/record.rb, line 99
def domain
  domain_id.present? ? (Domain.find domain_id) : nil
rescue ActiveResource::ResourceNotFound => e

  nil
end
domain_id() click to toggle source
# File lib/moniker/record.rb, line 95
def domain_id
  @prefix_options[:domain_id]
end
update_attributes(attributes) click to toggle source
Calls superclass method
# File lib/moniker/record.rb, line 91
def update_attributes(attributes)
  super attributes.merge @prefix_options
end

Protected Instance Methods

initialize(attributes = {}, persisted = false) click to toggle source
Calls superclass method
# File lib/moniker/record.rb, line 59
def initialize(attributes = {}, persisted = false) # :notnew:
  attributes = attributes.with_indifferent_access
  new_attributes = {
      :id => attributes[:id],
      :name => attributes[:name],
      :type => attributes[:type],
      :domain_id => attributes[:domain_id],
      :ttl => attributes[:ttl].present? ? attributes[:ttl].to_i : nil,
      :priority => attributes[:priority].present? ? attributes[:priority].to_i : nil,
      :data => attributes[:data],
      :updated_at => attributes[:created_at].present? ? DateTime.strptime(attributes[:created_at], Moniker::DATETIME_FORMAT) : nil,
      :created_at => attributes[:created_at].present? ? DateTime.strptime(attributes[:created_at], Moniker::DATETIME_FORMAT) : nil
  }

  super(new_attributes, persisted)
end