Using Hanami model and rake tasks without a router etc

172 Views Asked by At

I'm going to write a service that will using amqp protocol, without http at all. I like hanami's paradigm of repository-entity-model-interactors and I wonder to use those in my project. Generating all that stuff by hand, sure, is boring.

So, I wonder to grab rake tasks. Looking into config/environment etc, ughhhh. What is the best method, shortly, to use those tools without hanami router and controllers? Or, it is all integrated tightly?

As I think for that moment, there are two ways:

a) To include only hanami-model into my Gemfile, then copy by hand every needed file from gem hanami.

b) To create hanami project and do not use rackup.

I'm disappointed.

2

There are 2 best solutions below

0
On BEST ANSWER

Alternatively, you can add hanami as a development gem. That gives you access to the code generators. At the deploy stage, you don't bundle hanami, so the app will only have hanami-model and hanami-utils in production.

0
On

hello. If I understand you right, you want to use interactors only with models. Interactors you can use as a regular ruby library.

For model, you need to configure all this staff and load to memory. You can check the example from our playbook. Hope it'll be helpful for you

https://github.com/hanami/playbook/blob/master/development/bug_templates/model_psql.rb