Module Merb::Slices
In: lib/merb-slices/controller_mixin.rb
lib/merb-slices/module.rb
lib/merb-slices/module_mixin.rb

Methods

Classes and Modules

Module Merb::Slices::ControllerMixin
Module Merb::Slices::ModuleMixin
Module Merb::Slices::Support
Class Merb::Slices::Activate
Class Merb::Slices::DynamicLoader
Class Merb::Slices::Initialize
Class Merb::Slices::Loader

Constants

VERSION = "0.9.8"

External Aliases

activate_by_file -> register_and_load

Public Class methods

Retrieve a slice module by name

@param <to_s> The slice module to check for. @return <Module> The slice module itself.

Activate a Slice module at runtime

Looks for previously registered slices; then searches :search_path for matches.

@param slice_module<to_s> Usually a string of version of the slice module name.

Register a Slice by its gem/lib init file path and activate it at runtime

Normally slices are loaded using BootLoaders on application startup. This method gives you the possibility to add slices at runtime, all without restarting your app. Together with deactivate it allows you to enable/disable slices at any time. The router is reloaded to incorporate any changes. Disabled slices will be skipped when routes are regenerated.

@param slice_file<String> The path of the gem ‘init file‘

@example Merb::Slices.activate_by_file(’/path/to/gems/slice-name/lib/slice-name.rb’)

@return <Hash>

  The configuration loaded from Merb.root / "config/slices.yml" or, if
  the load fails, an empty hash.

Deactivate a Slice module at runtime

@param slice_module<to_s> The Slice module to unregister.

Deactivate a Slice module at runtime by specifying its slice file

@param slice_file<String> The Slice location of the slice init file to unregister.

Iterate over all registered slices

By default iterates alphabetically over all registered modules. If Merb::Plugins.config[:merb_slices][:queue] is set, only the defined modules are loaded in the given order. This can be used to selectively load slices, and also maintain load-order for slices that depend on eachother.

@yield Iterate over known slices and pass in the slice module. @yieldparam module<Module> The Slice module.

Check whether a Slice exists

@param <to_s> The slice module to check for.

Helper method to transform a slice filename to a module Symbol

A lookup for finding a Slice module‘s slice file path

@return <Hash> A Hash mapping module names to slice files. @note This is unaffected by deactivating a slice; used to reload slices by name.

@return <Hash[Hash]>

  A Hash mapping between slice identifiers and non-prefixed named routes.

A lookup for finding a Slice module‘s path

@return <Hash> A Hash mapping module names to root paths. @note Whenever a slice is deactivated, its path is removed from the lookup.

Register a Slice by its gem/lib path for loading at startup

This is referenced from gems/<slice-gem-x.x.x>/lib/<slice-gem>.rb Which gets loaded for any gem. The name of the file is used to extract the Slice module name.

@param slice_file<String> The path of the gem ‘init file’ @param force<Boolean> Whether to overwrite currently registered slice or not.

@return <Module> The Slice module that has been setup.

@example Merb::Slices::register(FILE) @example Merb::Slices::register(’/path/to/my-slice/lib/my-slice.rb’)

Look for any slices in Merb.root / ‘slices’ (the default) or if given, Merb::Plugins.config[:merb_slices][:search_path] (String/Array)

Reload a Slice at runtime

@param slice_module<to_s> The Slice module to reload.

Reload a Slice at runtime by specifying its slice file

@param slice_file<String> The Slice location of the slice init file to reload.

Slice file locations from all search paths; this default to host-app/slices.

Look for any slices in those default locations or if given, Merb::Plugins.config[:merb_slices][:search_path] (String/Array). Specify files, glob patterns or paths containing slices.

All registered Slice module names

@return <Array[String]> A sorted array of all slice module names.

All registered Slice modules

@return <Array[Module]> A sorted array of all slice modules.

Watch all specified search paths to dynamically load/unload slices at runtime

If a valid slice is found it‘s automatically registered and activated; once a slice is removed (or renamed to not match the convention), it will be unregistered and deactivated. Runs in a Thread.

@example Merb::BootLoader.after_app_loads { Merb::Slices.start_dynamic_loader! }

@param interval<Numeric>

  The interval in seconds of checking the search path(s) for changes.

Stop watching search paths to dynamically load/unload slices at runtime

Unregister a Slice at runtime

This clears the slice module from ObjectSpace and reloads the router. Since the router doesn‘t add routes for any disabled slices this will correctly reflect the app‘s routing state.

@param slice_module<to_s> The Slice module to unregister.

[Validate]