Class: Glare::CfDnsRecords
- Inherits:
-
Object
- Object
- Glare::CfDnsRecords
- Defined in:
- lib/glare/cf_dns_records.rb,
lib/glare/cf_dns_records/updater.rb
Defined Under Namespace
Classes: Updater
Class Method Summary collapse
Instance Method Summary collapse
- #any? ⇒ Boolean
- #calculate(desired_records) ⇒ Object
- #contents ⇒ Object
- #delete_if ⇒ Object
- #dup ⇒ Object
- #each ⇒ Object
-
#initialize(records) ⇒ CfDnsRecords
constructor
A new instance of CfDnsRecords.
- #map ⇒ Object
Constructor Details
#initialize(records) ⇒ CfDnsRecords
Returns a new instance of CfDnsRecords.
27 28 29 |
# File 'lib/glare/cf_dns_records.rb', line 27 def initialize(records) @records = records end |
Class Method Details
.empty ⇒ Object
22 23 24 |
# File 'lib/glare/cf_dns_records.rb', line 22 def empty new([]) end |
.from_result(api_response) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/glare/cf_dns_records.rb', line 7 def from_result(api_response) result = api_response.result records = result.map do |item| CfDnsRecord.new( id: item['id'], name: item['name'], type: item['type'], content: item['content'] ) end new(records) end |
Instance Method Details
#any? ⇒ Boolean
51 52 53 |
# File 'lib/glare/cf_dns_records.rb', line 51 def any? @records.any? { |record| yield(record) } end |
#calculate(desired_records) ⇒ Object
31 32 33 |
# File 'lib/glare/cf_dns_records.rb', line 31 def calculate(desired_records) Updater.new(@records.dup, desired_records.dup).calculate end |
#contents ⇒ Object
39 40 41 |
# File 'lib/glare/cf_dns_records.rb', line 39 def contents @records.map(&:content) end |
#delete_if ⇒ Object
55 56 57 |
# File 'lib/glare/cf_dns_records.rb', line 55 def delete_if @records.delete_if { |record| yield(record) } end |
#dup ⇒ Object
35 36 37 |
# File 'lib/glare/cf_dns_records.rb', line 35 def dup CfDnsRecords.new(@records.dup) end |
#each ⇒ Object
43 44 45 |
# File 'lib/glare/cf_dns_records.rb', line 43 def each @records.each { |record| yield(record) } end |
#map ⇒ Object
47 48 49 |
# File 'lib/glare/cf_dns_records.rb', line 47 def map @records.map { |record| yield(record) } end |