How to use inheritance in YAML files

#dev

YAML files are used to configure, but sometimes the configuration of one thing is similar to other ones with just one small difference. In YAML files it is possible to use inheritance to write those configurations.

For example, in Rails there is a config/database.yml to setup the database. If the database for development and test env are in the same host but with, obviously, different names:

development: &default
  adapter: postgresql
  encoding: unicode
  username: postgres
  host: db
  pool: 20
  database: app_development

test:
  <<: *default
  database: app_test

default is just a variable, you can use everything you want in that.