Sha256: 11c4f95132ebee98f93b2c4a2c283c8a2a7e8f46ff241142a3478627134191db

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

module Slices
  class Engine < Rails::Engine

    initializer :autoload_slices, before: :set_autoload_paths do |app|
      Slices.autoload_slices(app, Rails.root)
    end

    initializer :active_mongoid_observers do
      config.mongoid.observers.concat [:page_observer, :asset_observer]
    end

    initializer :slices_precompile_hook do |app|
      app.config.assets.precompile += %w(slices/slices.css slices/slices.js)
    end

    config.after_initialize do
      Slices.load_slice_classes_into_object_space(Rails.root)
    end

  end

  def self.autoload_slices(app, root)
    slice_dirs = Dir.glob(File.expand_path('app/slices/*', root))
    app.config.autoload_paths.push(*slice_dirs.select { |f| File.directory?(f) })
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slices-2.0.2 lib/slices/engine.rb
slices-2.0.1 lib/slices/engine.rb
slices-2.0.0 lib/slices/engine.rb