Sha256: ebe1dae500dfdcf3f3977240a45b35192174b65249230d7345228b1f7cb43d7d

Contents?: true

Size: 814 Bytes

Versions: 1

Compression:

Stored size: 814 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonmodel-0.0.1 lib/jsonmodel.rb