require 'active_model' require 'active_support/core_ext/class/attribute' require 'i18n' I18n.load_path << File.join(File.dirname(__FILE__), "config", "locales", "en.yml") module JSONModel require 'jsonmodel/types' require 'jsonmodel/validations' require 'jsonmodel/attributes' require 'jsonmodel/persistence' require 'jsonmodel/naming' # The purpose of the Base class is to allow injection of modules in the # dynamic classes generated by self.from_hash class Base class_attribute :schema include JSONModel::Persistence include ActiveModel::Conversion end def self.from_hash(schema) Class.new(Base) do self.schema = schema include JSONModel::Attributes include JSONModel::Validations include JSONModel::Naming end end end