account_location and domain forwarding

i'm playing around with an idea i had for using a rails app with multiple domains. i used the account_location plugin which works great.

however, eventually i would like to do something similar to shopify where they allow you to add dns entries to your own domain and forward it to the subdomain on their site. for instance, i could have mystore.myshopify.com and add a cname record so that shop.mydomain.com would point to that, or even a top level domain like mydomain.com.

i'm not very knowledgeable when it comes to dns, so i don't know how it works. but is there a way to set the account_location plugin to handle something like that or would i have to do some sort of dns lookup to make sure the requesting domain matches an account that's set up?