Sha256: ebcdfada9a43156233624c0aa81c8b8a6feee371abe703cb7a97b0adb551f491

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

require 'slim'
require 'cm_admin/version'
require 'cm_admin/engine'
require 'cm_admin/model'
require 'cm_admin/view_helpers'
require 'cm_admin/utils'
require 'cm_admin/configuration'

module CmAdmin
  class Error < StandardError; end

  mattr_accessor :layout, :authorized_roles
  mattr_accessor :included_models, :cm_admin_models
  @@authorized_roles ||= []
  @@included_models ||= []
  @@cm_admin_models ||= []

  class << self
    def configure
      # instance_eval(&block)
      @config ||= Configuration.new
      yield(@config)
    end

    def layout; end

    def config
      @config ||= Configuration.new
    end

    def initialize_model(entity, &block)
      return unless entity.is_a?(Class)
      return if CmAdmin::Model.find_by({ name: entity.name })

      config.cm_admin_models << CmAdmin::Model.new(entity, &block)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cm-admin-4.1.0 lib/cm_admin.rb
cm-admin-4.0.0 lib/cm_admin.rb