Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Nikita Shilnikov
@flash-gordon
it does not
Rafael George
@cored
I was wondering if dry-rb would be to hard to plug into an existent Rails project if that maybe would be better to just use somthing like 'wisper' to define service objects and reduce the coupling through the pub/sub pattern implementation
@flash-gordon ?
In a real app, you should consider using dry-system to make it easier to populate a container with your own objects.
that's part of dry-transaction documentation
Nikita Shilnikov
@flash-gordon
dry-transaction usually uses a container but you can set up it by yourself, no dry-system needed for that
easier <- that's the word
Rafael George
@cored
ok
I don't know if this idea make sense, like moving into dry-rb on the current rails application that I'm working on
my intention is just to reduce teh coupling and have better composabilities capabilities in the code base so I can build more complex features for the app
Nikita Shilnikov
@flash-gordon
@cored answering your question, problems can arise around AS loading mechanism but anything else should work fine
Rafael George
@cored
got it
I will have to know how to work around the limitations of Rails
I don't normally use the repository pattern since I use the active record model as teh repository instead
removing most business logic from it
Sean Collins
@cllns
Using dry-struct and it is so. nice. :) thanks y'all!
Ahmad Musaffa
@musaffa
@gotar dry-web-blog is just a generated app. There's nothing new in it.
Tim Riley
@timriley
I haven’t had a chance to make anything yet, I hope I can soon, @musaffa
Ahmad Musaffa
@musaffa
How do you return a json response with dry-web-roda? Is dry-view appropriate for placing json response code?
Tim Riley
@timriley
@musaffa yep, you can use the tilt yajl engine and .json.yajl templates
That's one option, anyway. I'm sure there are others.
Ahmad Musaffa
@musaffa

I've enabled json plugin for roda and put this code:

# lib/dwimiklab_api/articles/views/show.rb
require 'dwimiklab_api/import'

module DwimiklabApi
  module Articles
    module Views
      class Show
        include DwimiklabApi::Import['articles.repository']

        def call(id)
          repository[id]
        end
      end
    end
  end
end

# web/routes/articles.rb
module DwimiklabApi
  class Application
    route 'articles' do |r|
      r.on ':id' do |id|
        r.resolve 'articles.views.show' do |show|
          show.(id).to_hash
        end
      end
    end
  end
end

I've removed dry-view because all I need is some json responses.

Tim Riley
@timriley
👍🏼
shd88
@shd88
C
Piotr Solnica
@solnic
@andriytyurnikov @flash-gordon actually yes, I do plan to build a data generator using dry-types (early beginning of this can be found in rom-factory project)
Brendon Murphy
@bemurphy
Just checking to make sure I've got this straight: dry-transaction expects every service it calls to have a call method with arity 1. So if I wanted to say, pass along a user and a password from say, a CreateUser step...
Tim Riley
@timriley
@bemurphy yes, right now we expect arity of 1 (turns out doing otherwise gets tricky)
so you could pass those two things as keyword args/hash
or make your own object that encapsulates the two, if it’s something you pass around a lot
Brendon Murphy
@bemurphy
# Go
Dry::Monads::Right(user: user, password: password)
# No go
Dry::Monads::Right(user, password)
Tim Riley
@timriley
Yep, that’s right
Brendon Murphy
@bemurphy
@timriley cool, thanks
Tim Riley
@timriley
We played with splatting arrays returned from operations into separate args for the next step
but the problem there is: what if you actually want to return a single real array?
Brendon Murphy
@bemurphy
ah yeah, good point
Tim Riley
@timriley
I think we’d need to add another concept to dry-transaction to support variable args from step-to-step
some kind of result object
Brendon Murphy
@bemurphy
This is pretty edge anyhow, apparently I went to experiment first with the flow that's irritated me since 2006 (setting a temporary password, with a value not available to another instance)
in general, I can't imagine hitting a case where I couldn't just pass an instance down the pipe
Tim Riley
@timriley
Yeah. I feel, in a way, this limitation is a good thing - it might encourage people to make a real value object to encapsulate commonly passed bundles of data
Brendon Murphy
@bemurphy
for sure. I got it working with a hash, but then a few places I consume it, I'm calling #fetch out of paranoia. Seems like a payload object is warranted.
Brendon Murphy
@bemurphy
Yup, that works, took all of about 4 lines. Thanks for the idea.
Tim Riley
@timriley
Awesome!
Piotr Solnica
@solnic
we should make monads accept a single arg
people will be tripping on this
Tim Riley
@timriley
@solnic as in, leave it just like it is now?
Piotr Solnica
@solnic
no, stop accepting Right(foo, bar)
so *args => arg
Tim Riley
@timriley
@solnic we don't accept right(foo, bar) already
Nikita Shilnikov
@flash-gordon
mb I'm missing something but it always worked like that