Sha256: a0a930425d396b4553abd281c3c4635f0b06ba119370fa2ba2d38542dd0d38ae

Contents?: true

Size: 1.03 KB

Versions: 49

Compression:

Stored size: 1.03 KB

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 webpacker
      @webpacker ||= ::Webpacker::Instance.new(
        root_path: CmAdmin::Engine.root,
        config_path: CmAdmin::Engine.root.join('config', 'webpacker.yml')
      )
    end

    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

49 entries across 49 versions & 1 rubygems

Version Path
cm-admin-3.0.16 lib/cm_admin.rb
cm-admin-3.0.15 lib/cm_admin.rb
cm-admin-3.0.14 lib/cm_admin.rb
cm-admin-3.0.13 lib/cm_admin.rb
cm-admin-3.0.12 lib/cm_admin.rb
cm-admin-3.0.11 lib/cm_admin.rb
cm-admin-3.0.10 lib/cm_admin.rb
cm-admin-3.0.9 lib/cm_admin.rb
cm-admin-3.0.8 lib/cm_admin.rb
cm-admin-3.0.7 lib/cm_admin.rb
cm-admin-3.0.6 lib/cm_admin.rb
cm-admin-3.0.5 lib/cm_admin.rb
cm-admin-3.0.4 lib/cm_admin.rb
cm-admin-3.0.3 lib/cm_admin.rb
cm-admin-3.0.2 lib/cm_admin.rb
cm-admin-3.0.1 lib/cm_admin.rb
cm-admin-3.0.0 lib/cm_admin.rb
cm-admin-2.4.6 lib/cm_admin.rb
cm-admin-2.4.5 lib/cm_admin.rb
cm-admin-2.4.4 lib/cm_admin.rb