Class: RactorDNS::FrozenZoneCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/ractor_dns/zone_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ FrozenZoneCollection

Returns a new instance of FrozenZoneCollection.



91
92
93
# File 'lib/ractor_dns/zone_collection.rb', line 91

def initialize(obj)
  @obj = Ractor.make_shareable(obj.freeze)
end

Instance Method Details

#[](k) ⇒ Object



95
96
97
# File 'lib/ractor_dns/zone_collection.rb', line 95

def [](k)
  @obj[k]
end

#search(name) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ractor_dns/zone_collection.rb', line 99

def search(name)
  if name.nil?
    return nil
  end
  
  if name.is_a? RRs::Name
    name = name.to_a
  end
  
  if name.length > 1
    @obj.dig(name.join(".")).presence || search(name.drop(1))
  else
    @obj.dig(name)
  end
end