On second thought, I think the following is cleaner:

```ruby
  #...
  add_resource_descriptor_to_dereferencing_queue(hash_descriptor)
  add_resource_descriptor_to_registry(hash_descriptor, raw_descriptor_registry)
end

def add_resource_descriptor_to_registry(hash_descriptor, registry)
  Crichton::Descriptor::Resource.new(hash_descriptor).tap do |resource_descriptor|
    add_resource_descriptor_to_raw_profile_registry(resource_descriptor) if registry == raw_descriptor_registry

    resource_descriptor.descriptors.each do |descriptor|
      if registry[descriptor.id]
        raise ArgumentError, "Resource descriptor for #{descriptor.id} is already registered."
      end
      registry[descriptor.id] = descriptor
    end
  end
end

def add_resource_descriptor_to_raw_profile_registry(resource_descriptor)
  if raw_profile_registry[resource_descriptor.id]
    raise ArgumentError, "Resource descriptor profile for #{resource_descriptor.id} is already registered."
  else
   raw_profile_registry[resource_descriptor.id] = resource_descriptor
  end
end
```