Modules
Modules in Rhino provide and extend the functionality of the core application. They are intended to be used for functionality that is not required by all users of Rhino, but is required by some. Organizations, Jobs, Notifications, Subscriptions are all examples of modules.
Modules are created as "full" Rails plugins and backed by Engines in Rails and are installed initially via Generators.
Creating
A new module can be created with
rails rhino:module:new
and a mountable module with
rails rhino:module:new --mountable
Module names should describe the functionality provided rather than the technology used, for instance 'rhino_subscriptions' instead of 'rhino_stripe'.
Installation
Each module provides an installation command for instance
rails rhino_jobs:install
that installs migrations (if any) and allows you to do any other setup work in install_generator.rb
.
Registration
Modules should register themselves and metadata as appropriate in engine.rb
:
initializer 'rhino_organizations.register_module' do
config.after_initialize do
Rhino.registered_modules[:rhino_organizations] = {
version: RhinoOrganizations::VERSION
allow_signup: true
}
end
end
Testing
After creating the module, tests are runnable with
rails rhino:module:test MODULE_NAME
and can be added to the CircleCI job to generate coverage
rails rhino:module:coverage MODULE_NAME
Full modules have a dummy app for testing. This can be setup and used as follows
rails rhino:module:dummy MODULE_NAME db:setup
rails rhino:module:dummy MODULE_NAME server