module Mimi::Core::Module::ClassMethods

Public Instance Methods

configure(opts = {}) click to toggle source

Processes given values for configurable parameters defined in the module manifest and populates the options Hash.

@param opts [Hash] values for configurable parameters

# File lib/mimi/core/module.rb, line 23
def configure(opts = {})
  manifest_hash = manifest
  unless manifest_hash.is_a?(Hash)
    raise "#{self}.manifest should be implemented and return Hash"
  end
  @options = Mimi::Core::Manifest.new(manifest_hash).apply(opts)
end
manifest() click to toggle source

Module manifest

Mimi modules overload this method to define their own set of configurable parameters. The method should return a Hash representation of the manifest.

NOTE: to avoid clashes with other modules, it is advised that configurable parameters for the module have some module-specific prefix. E.g. `Mimi::DB` module has its configurable parameters names as `db_adapter`, `db_database`, `db_username` and so on.

@see Mimi::Core::Manifest

@return [Hash]

# File lib/mimi/core/module.rb, line 69
def manifest
  {}
end
module_path() click to toggle source

Returns the path to module files, if the module exposes any files.

Some modules may expose its files to the application using Mimi core. For example, a module may contain some rake tasks with useful functionality.

To expose module files, this method must be overloaded and point to the root of the gem folder:

“` # For example, module my_lib folder and files: /path/to/my_lib/

./lib/my_lib/...
./lib/my_lib.rb
./spec/spec_helper
...

# my_lib module should expose its root as .module_path: /path/to/my_lib “`

@return [Pathname,String,nil]

# File lib/mimi/core/module.rb, line 52
def module_path
  nil
end
options() click to toggle source

Returns a Hash of configurable parameter values accepted and set by the `.configure` method.

@return [Hash<Symbol,Object>]

# File lib/mimi/core/module.rb, line 106
def options
  @options || {}
end
start(*) click to toggle source

Starts the module.

Mimi modules overload this method to implement some module-specific logic that should happen on application startup. E.g. `mimi-messaging` establishes a connection with a message broker and declares message consumers.

# File lib/mimi/core/module.rb, line 79
def start(*)
  @module_started = true
end
started?() click to toggle source

Returns true if the module is started.

@return [true,false]

# File lib/mimi/core/module.rb, line 87
def started?
  @module_started
end
stop(*) click to toggle source

Starts the module.

Mimi modules overload this method to implement some module-specific logic that should happen on application shutdown. E.g. `mimi-messaging` closes a connection with a message broker.

# File lib/mimi/core/module.rb, line 97
def stop(*)
  @module_started = false
end