Support for definitions

Added definitions support and moved some common code into ```base_model.rb```