Sha256: d66fcd8f8d14f634f0c32f5d23fb75da8f81c0b537db1516330112c5222fad34

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require 'ditty'

module Ditty
  class App
    def self.load
      controllers = File.expand_path('../controllers', __dir__)
      Dir.glob("#{controllers}/*.rb").each { |f| require f }

      require 'ditty/models/user'
      require 'ditty/models/role'
      require 'ditty/models/identity'
      require 'ditty/models/audit_log'
    end

    def self.configure(_container)
      require 'ditty/db' unless defined? ::DB
      require 'ditty/listener'
    end

    def self.migrations
      File.expand_path('../../../migrate', __dir__)
    end

    def self.view_folder
      File.expand_path('../../../views', __dir__)
    end

    def self.routes
      load
      {
        '/' => ::Ditty::Main,
        '/auth' => ::Ditty::Auth,
        '/users' => ::Ditty::Users,
        '/roles' => ::Ditty::Roles,
        '/audit-logs' => ::Ditty::AuditLogs
      }
    end

    def self.navigation
      load

      [
        {
          group: 'User Management',
          order: 10,
          icon: 'lock',
          target: ::Ditty::User,
          items: [
            { order: 10, link: '/users/', text: 'Users', target: ::Ditty::User, icon: 'user' },
            { order: 20, link: '/roles/', text: 'Roles', target: ::Ditty::Role, icon: 'check-square' },
            { order: 30, link: '/audit-logs/', text: 'Audit Logs', target: ::Ditty::AuditLog, icon: 'history' }
          ]
        }
      ]
    end

    def self.seeder
      proc do
        load

        ::Ditty::Role.find_or_create(name: 'super_admin')
        ::Ditty::Role.find_or_create(name: 'admin')
        ::Ditty::Role.find_or_create(name: 'user')
      end
    end
  end
end

Ditty::Components.register_component(:app, Ditty::App)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ditty-0.7.2 lib/ditty/components/app.rb