Class: RactorDNS::ActiveZone::ZoneCollection
- Inherits:
-
ActiveZone::Provider::ZoneCollection
- Object
- ActiveZone::Provider::ZoneCollection
- RactorDNS::ActiveZone::ZoneCollection
- Defined in:
- lib/ractor_dns/active_zone/zone_collection.rb
Instance Method Summary collapse
- #[](n) ⇒ Object
- #destroy_all ⇒ Object
- #each(&block) ⇒ Object
- #find(name) ⇒ Object
- #find_by(attributes = {}) ⇒ Object
Instance Method Details
#[](n) ⇒ Object
35 36 37 |
# File 'lib/ractor_dns/active_zone/zone_collection.rb', line 35 def [](n) RactorDNS::ActiveZone::Zone.new(resources: provider.zones.to_h.values[n], persisted: true, name: provider.zones.to_h.keys[n]) end |
#destroy_all ⇒ Object
16 17 18 19 20 |
# File 'lib/ractor_dns/active_zone/zone_collection.rb', line 16 def destroy_all each do |z| z.destroy end end |
#each(&block) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/ractor_dns/active_zone/zone_collection.rb', line 6 def each(&block) if block_given? provider.zones.to_h.keys.filter { |el| @set ? @set.include?(el.name) : true }.each do |zk| block.call(RactorDNS::ActiveZone::Zone.new(resources: provider.zones[zk], name: zk, persisted: true)) end else to_enum(:each) end end |
#find(name) ⇒ Object
2 3 4 |
# File 'lib/ractor_dns/active_zone/zone_collection.rb', line 2 def find(name) RactorDNS::ActiveZone::Zone.new(resources: provider.zones[name], name: name, persisted: true) if provider.zones[name] end |
#find_by(attributes = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ractor_dns/active_zone/zone_collection.rb', line 22 def find_by(attributes = {}) each do |z| broken = false attributes.each do |k, v| if v != z[k] broken = true break end end return z if !broken end end |