Sha256: a2679484b8cbb68b49671b59dea9a5c633bed7f989f81ab8ecc24abf675b5529
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
# -*- encoding : utf-8 -*- module RademadeAdmin module Model class Reflection attr_reader :model, :controller def initialize(model, controller) @model, @controller = model, controller end ORM_TYPE_ACTIVERECORD = 'ActiveRecord' ORM_TYPE_MONGOID = 'Mongoid' # Load data adapter for current model # # @return [RademadeAdmin::Model::Adapter::Data] def data_adapter @data_adapter ||= "RademadeAdmin::Model::Adapter::Data::#{orm_type}".constantize.new(@model) end # Load query adapter for current model # # @return [RademadeAdmin::Model::Adapter::Query] def query_adapter @query_adapter ||= "RademadeAdmin::Model::Adapter::Query::#{orm_type}".constantize.new(@model) end protected def _model_ancestors @model_ancestors = @model.ancestors.map(&:to_s) end def orm_type return @orm_type unless @orm_type.nil? orm_list.each do |orm_class, orm_type| @orm_type = orm_type if _model_ancestors.include? orm_class end @orm_type end def orm_list @orm_list ||= { 'ActiveRecord::Base' => ORM_TYPE_ACTIVERECORD, 'Mongoid::Document' => ORM_TYPE_MONGOID } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems