0.0
There's a lot of open issues
No release in over a year
A Rails wrapper for the `nucleus-core` gem
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0.1.0
 Project Readme

Nucleus Rails

Gem Version Circle Code Climate

  • Quick start
  • Support
  • License
  • Code of conduct
  • Contribution guide

nucleus-rails adapts nucleus-core to work with the rails framework.

Quick start

  1. Install the gem

Gemfile

gem 'nucleus-rails'
  1. Initialize nucleus-rails

config/initializers/nucleus-rails.rb

require "nucleus-rails"

NucleusCore.configure do |config|
  config.exceptions = {
    not_found: ActiveRecord::RecordNotFound,
    unprocessible: [ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved],
    bad_request: Apipie::ParamError,
    unauthorized: Pundit::NotAuthorizedError
  }
end
  1. Include the responder module in your controller, call your business logic inside execute block, then return either a NucleusView, a Nucleus::Operation::Context, or raise an exception to render a response.
class PaymentsController < ApplicationController
  include NucleusRails::Responder

  def create
    render_response do |req|
      context, _process = MyWorkflow.call(id: req.parameters[:id])

      return context unless context.success?

      return MyView.new(resource: context.resource)
    end
  end

  def show
    context = MyOperation.call(id: params[:id])

    return render_entity(context) unless context.success?

    return render_entity(MyView.new(resource: context.resource))
  end
end

Support

If you want to report a bug, or have ideas, feedback or questions about the gem, let me know via GitHub issues and I will do my best to provide a helpful answer. Happy hacking!

License

The gem is available under the terms of the proprietary software 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!