I am reviewing a piece of code from a Rails project and I came across the `tap` method. What does it do?

Also, it would be great if someone could help me understand what the rest of the code does:

```
def self.properties_container_to_object properties_container
  {}.tap do |obj|
  obj['vid'] = properties_container['vid'] if properties_container['vid']
  obj['canonical-vid'] = properties_container['canonical-vid'] if   properties_container['canonical-vid']
  properties_container['properties'].each_pair do |name, property_hash|
  obj[name] = property_hash['value']
  end
 end
end

```

Thanks!