Sha256: e3f7e356cfc588b501966df2abacbf354d1487621bf5f8855d2926dd399de926

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

# -*- encoding : utf-8 -*-
module RademadeAdmin
  module Model
    class Graph
      include Singleton

      def add_pair(controller_name, inner)
        controller_full_name = ('rademade_admin/' + controller_name + '_controller')
        controller = controller_full_name.camelize.constantize
        model = controller.model_class
        unless @model_infos[model.to_s]
          model_reflection = Reflection.new(model, controller_name, controller_full_name, inner)
          @model_infos[model.to_s] = controller.init_model_info(model_reflection)
        end
      end

      def model_info(model)
        @model_infos[model.to_s]
      end

      def root_models
        @root_models ||= get_root_models
      end

      private

      def initialize
        @model_infos = {}
      end

      def get_root_models
        @model_infos.select { |model_name, model_info| not model_info.nested? }.values
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rademade_admin-0.0.3 lib/rademade_admin/model/graph.rb
rademade_admin-0.0.2 lib/rademade_admin/model/graph.rb