Sha256: 17ef921e37d0339ecf1fc46dfd91ebd752d324cd9202973fd74a59dc5e627dc3

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

module Smithy
  class Engine < ::Rails::Engine
    isolate_namespace Smithy

    class << self
      attr_accessor :root
      def root
        @root ||= Pathname.new(File.expand_path('../../', File.dirname(__FILE__)))
      end
    end

    config.autoload_paths += %W(#{config.root}/lib)

    config.to_prepare do
      # include the Smithy helpers in the host application
      ::ApplicationController.send :helper, Smithy::Engine.helpers
    end

    config.generators do |g|
      g.test_framework :rspec, :fixture => false, :view_specs => false
      g.integration_tool :rspec
      g.fixture_replacement :factory_girl, :dir => 'spec/factories'
      g.assets false
      g.helper false
    end

    config.after_initialize do
      # We need to reload the routes here due to how Smithy sets them up.
      # The different facets of Smithy (auth) append/prepend routes to Smithy
      # *after* the main engine has been loaded.
      #
      # So we wait until after initialization is complete to do one final reload.
      # This then makes the appended/prepended routes available to the application.
      Rails.application.routes_reloader.reload!
      # we need to require all our model files so that ContentBlocks
      # are registered with the engine
      Dir[Smithy::Engine.root.join('app', 'models', 'smithy', '*.rb')].each do |file|
        require_dependency file if ActiveRecord::Base.connection.table_exists?(file.pluralize)
      end
    end

    # TODO: Abstract out the configuration
    # initializer "smithy.config", :before => :load_config_initializers do |app|
    #   Smithy::Config = app.config.smithy.preferences
    # end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smithycms-0.0.3 lib/smithy/engine.rb
smithycms-0.0.2 lib/smithy/engine.rb
smithycms-0.0.1 lib/smithy/engine.rb