Sha256: b217991a43f34808cab1853e6fb500aa406bbe9b25fbb2afae7dc32b09bf2105

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'rails/engine'

module Adva
  autoload :Engine,     'adva/engine'
  autoload :Generators, 'adva/generators'
  autoload :Rack,       'adva/rack'
  autoload :Registry,   'adva/registry'
  autoload :Responder,  'adva/responder'
  autoload :Tasks,      'adva/tasks/core'
  autoload :Testing,    'adva/testing'
  autoload :View,       'adva/view'

  mattr_accessor :out
  self.out = $stdout

  class << self
    def engines
      @engines ||= constants.map do |name|
        constant = const_get(name)
        constant if constant != Adva::Core && constant.is_a?(Class) && constant < ::Rails::Engine
      end.compact.sort { |lft, rgt| lft.name <=> rgt.name }.unshift(Adva::Core)
    end

    def engine(name)
      name = "Adva::#{name.camelize}" unless name.to_s.starts_with?('Adva::')
      engines.detect { |engine| engine.name == name }
    end

    def engine_names
      @engine_names ||= engines.map { |constant| constant.name.split('::').last.underscore.to_sym }
    end

    def engine?(name)
      engine_names.include?(name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adva-core-0.0.2 lib/adva.rb
adva-core-0.0.1 lib/adva.rb