Class: Moniker::Record
- Inherits:
-
Common
- Object
- ActiveResource::Base
- Base
- Common
- Moniker::Record
- Defined in:
- lib/moniker/record.rb
Overview
A Moniker Domain
Attributes
-
name- Name of this image -
email- e-mail of the registrant -
ttl- domain ttl -
serial- domain serial -
updated_at- Modification date -
created_at- Creation date
Class Method Summary collapse
- .find_all_by_data(data, options = {}) ⇒ Object
- .find_all_by_name(name, options = {}) ⇒ Object
- .find_all_by_type(type, options = {}) ⇒ Object
- .find_by_name(name, options = {}) ⇒ Object
Instance Method Summary collapse
- #domain ⇒ Object
- #domain_id ⇒ Object
-
#encode(options = {}) ⇒ Object
Overloads ActiveRecord::encode method.
-
#initialize(attributes = {}, persisted = false) ⇒ Record
constructor
:notnew:.
- #update_attributes(attributes) ⇒ Object
Methods inherited from Common
collection_path, custom_method_collection_url, element_path
Methods inherited from Base
Methods inherited from ActiveResource::Base
Constructor Details
#initialize(attributes = {}, persisted = false) ⇒ Record
:notnew:
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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 |
Class Method Details
.find_all_by_data(data, options = {}) ⇒ Object
118 119 120 |
# File 'lib/moniker/record.rb', line 118 def self.find_all_by_data(data, = {}) all().select { |record| record.data == data } end |
.find_all_by_name(name, options = {}) ⇒ Object
110 111 112 |
# File 'lib/moniker/record.rb', line 110 def self.find_all_by_name(name, = {}) all().select { |record| record.name == name } end |
.find_all_by_type(type, options = {}) ⇒ Object
114 115 116 |
# File 'lib/moniker/record.rb', line 114 def self.find_all_by_type(type, = {}) all().select { |record| record.type == type } end |
.find_by_name(name, options = {}) ⇒ Object
106 107 108 |
# File 'lib/moniker/record.rb', line 106 def self.find_by_name(name, = {}) all().detect { |record| record.name == name } end |
Instance Method Details
#domain ⇒ Object
99 100 101 102 103 104 |
# 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 ⇒ Object
95 96 97 |
# File 'lib/moniker/record.rb', line 95 def domain_id [:domain_id] end |
#encode(options = {}) ⇒ Object
Overloads ActiveRecord::encode method
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/moniker/record.rb', line 78 def encode(={}) # :nodoc: Custom encoding to deal with moniker API to_encode = { :name => name, :type => type, :data => data } to_encode[:ttl] = ttl if ttl.present? to_encode[:priority] = priority if priority.present? to_encode.send("to_#{self.class.format.extension}", ) end |
#update_attributes(attributes) ⇒ Object
91 92 93 |
# File 'lib/moniker/record.rb', line 91 def update_attributes(attributes) super attributes.merge end |