Nucleus Core Ruby
- Overview
- Supported Frameworks
- Support
- License
- Code of conduct
- Contribution guide
Overview
Nucleus-Core-Ruby is an opinionated way to express business logic agnostically to your framework, and prescribes request/response handling as follows:
**Device**
* Receives request
-----------------------------------------------------------------------------------
**Framework**
* Formats request parameters and passes them to a receiver
-----------------------------------------------------------------------------------
**Business Logic**
* Authenticate
* Authorize
* Execute Operation/Workflow
* Interact with data source via a Repository
* Return view object given Operation/Workfow result
-----------------------------------------------------------------------------------
**Framework**
* Renders view object to the requested format
-----------------------------------------------------------------------------------
**Device**
* Device displays output to the medium it serves
Getting started
- Install the gem
gem install 'nucleus-core'
- Initialize and configure
require "nucleus-core"
NucleusCore.configure do |config|
config.logger = Logger.new($stdout)
config.default_response_format = :json # defaults to :json
# The request_exceptions attribute allows you to define custom exception handling for different
# HTTP error types. The keys are standard error names like :bad_request, :unauthorized, and :not_found,
# and the values are the exception classes or errors you want to handle for each case.
config.request_exceptions = {
not_found: RecordNotFound,
unprocessible: [RecordInvalid, RecordNotSaved],
bad_request: ArgumentError,
forbidden: NotPermittedError,
unauthorized: UnAuthenticatedError
}
end
- Refer to the 'How-To' section for guidance on expressing your business logic.
Supported Frameworks
Support
If you want to report a bug, or have ideas, feedback or questions about the gem, let me know via GitHub issues and we will do our best to provide a helpful answer.
License
The gem is available as open source under the terms of the MIT License.
Code of conduct
Everyone interacting in this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Contribution guide
Pull requests are welcome!