A simple "Workflow" service utility belt.
Add this line to your application's Gemfile:
gem 'Juno', github: "RepPro/Juno"
And then execute:
$ bundle
Or install it yourself as:
$ gem install Juno
Juno current provides two composable utilties.
###Juno.active_record
Provides a single helper, transact!
, to deal with active record transactions and handling failure.
class Create
include Juno.active_record
def call
transact! {@user.create!(name: "James Brown")}
end
end
Transact will wrap the passed in block in an ActiveRecord::Base.transaction
and rescue the exception. That exception will then be pushed into a @errors
ivar.
###Juno.service
Provides a set of helpers to construct workflows.
class Create
include Juno.service
def call
do_something
end
end
By including Juno.service
you will get the following:
- A
.call
class method with wildcard arity that will instantiate your class and pass all args to yourcall
method. attr_reader
forparams
anderrors
- A
_params
method to unwrap your params if they are still an instance ofStrongParams
.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/RepPro/Juno.