Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Tim Riley
@timriley
Thanks @AMHOL :D
Oskar Szrajer
@gotar
[5] pry(main)> Athit::Container["notifications"] => #<Dry::Monitor::Notifications:0x0055aae85b7d70 @clock=#<Dry::Monitor::Clock:0x0055aae84c91c0>, @events= {:"rack.request.start"=>#<Dry::Monitor::Event:0x0055aae85b7618 @id=:"rack.request.start", @info={}>, :"rack.request.stop"=>#<Dry::Monitor::Event:0x0055aae85b7578 @id=:"rack.request.stop", @info={}>, :"rack.request.error"=>#<Dry::Monitor::Event:0x0055aae85b74b0 @id=:"rack.request.error", @info={}>, :sql=>#<Dry::Monitor::Event:0x0055aae99ccc20 @id=:sql, @info={}>}, @id=:core, @listeners= {:"rack.request.start"=> [#<Proc:0x0055aae85b6b28@/home/gotar/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/dry-monitor-0.0.2/lib/dry/monitor/rack/logger.rb:33>], :"rack.request.stop"=> [#<Proc:0x0055aae85b6a88@/home/gotar/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/dry-monitor-0.0.2/lib/dry/monitor/rack/logger.rb:37>], :"rack.request.error"=> [#<Proc:0x0055aae85b6948@/home/gotar/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/dry-monitor-0.0.2/lib/dry/monitor/rack/logger.rb:41>], :sql=>[#<Proc:0x0055aae99ccbd0@/home/gotar/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/dry-monitor-0.0.2/lib/dry/monitor/sql/logger.rb:29>]}> [6] pry(main)>
@timriley ^
yes I have
Tim Riley
@timriley
@gotar odd! Would you mind sharing a full stack trace for me?
Oskar Szrajer
@gotar
[5] pry(main)> Main::Container["persistence.repositories.users"][1] NoMethodError: undefined method `instrument' for nil:NilClass from /home/gotar/Programowanie/Athit/lib/rom/instrumentation.rb:14:in `to_a
that's all
those 14 line is: notifications.instrument(:sql, name: name.relation, query: dataset.sql)
and notifications are just nil
Piotr Rybarczyk
@Argonus
Hi, i am using dry-validation and dry-struc gems in project. But i see a problem with boolean values in params, i am receiving it as 'true' or 'false', and bool? validation fails. I need to map them or i just cant find some info in documentation
Nikita Shilnikov
@flash-gordon
@Argonus you need to use Dry::Validation.Form for such coercions
Piotr Rybarczyk
@Argonus
@flash-gordon Thanks, i had to be blind...
Gustavo Caso
@GustavoCaso
Hello everyone
Excited to be here and been able to try the dry-rb gems
Hope to contribute to all this new libraries
Tim Riley
@timriley
Welcome, @GustavoCaso! Looking forward to hearing how they go for you.
@gotar Ah! Now I’m back on a computer, I have a feeling your problem might be that you have a Athit::Container["notifications”], but not a Main::Container[“notifications”].
is your rom bootable dep inside the Athit or Main system?
Oskar Szrajer
@gotar
inside Athit
gotar ~/Programowanie/Athit (master) ~ $ tree system/
system/
├── athit
│   ├── application.rb
│   ├── assets.rb
│   ├── container.rb
│   ├── import.rb
│   └── settings.rb
├── boot
│   ├── bugsnag.rb
│   ├── i18n.rb
│   ├── monitor.rb
│   └── rom.rb
└── boot.rb

2 directories, 10 files
@timriley probably you guys will update berg in the (i hope near) feature. So I will check there and compare where I might have a problem
Alejandro E. Babio
@alejandrobabio

Hi, I'm thinking on move business logic to a dry-transaction in a Rails app. As first try I built a class for create a Post:

class Post
  class Container
    extend Dry::Container::Mixin

    register :build_params, -> (params) {
      Dry::Monads.Right(params[:post])
    }

    register :validate, -> (input) {
      if input[:body].nil? || input[:title].nil?
        Dry::Monads.Left(:not_valid)
      else
        Dry::Monads.Right(input)
      end
    }

    register :persist, -> (input) {
      Post.create Dry::Monads.Right(input)
    }
  end

  class CreatePost
    def initialize(params)
      save_user = Dry.Transaction(container: Container) do
        step :build_params
        step :validate
        step :persist
      end
      save_user.call(params)
    end
  end
end

It should create a new Post when it's called with:

Post::CreatePost.new(post: {body: 'ab', title: 'AB'})

But I'm getting the error:

NoMethodError: undefined method `Right' for Dry::Monads:Module
from /home/alejandro/.rvm/gems/ruby-2.3.3@rails501/gems/dry-transaction-0.9.0/lib/dry/transaction/api.rb:40:in `call'

Have you some idea of what I'm doing wrong? I tried to build something pretty similar to the basic example of dry-transaction.

Nikita Shilnikov
@flash-gordon
@alejandrobabio can be easily fixed with require 'dry/monads' :)
Alejandro E. Babio
@alejandrobabio
Good! Thank you!
Nikita Shilnikov
@flash-gordon
not all the monads are required for dry-transaction hence those methods are not required by default
Alejandro E. Babio
@alejandrobabio
Thanks for say that. Now it's working.
Piotr Solnica
@solnic
@gotar I think I know why you had issues with instrumentation patch in rom, you basically can’t boot!(:rom) too early, otherwise patch won’t be applied before your relations are built
Oskar Szrajer
@gotar
yeah i assume it's condition problem, is there a way to force order, like in rom force loading monit first? maybe in init?
@solnic
for now i just add:
        notifications ||= Athit::Container[:notifications]
        notifications.instrument(:sql, name: name.relation, query: dataset.sql) do
          super
        end
works, but it's ugly hack
Oskar Szrajer
@gotar
:facepalm: ok fixed ;]
there is just use :monitor missing in rom boot file (init section)
@timriley @solnic
so probably should be added to dry-web-roda geenrator too
thx guys for help
Oskar Szrajer
@gotar
@timriley I already add those missing line to dry-web-roda skeleton apps
Tim Riley
@timriley
@gotar oh! Would you mind PR-ing this? I'll add you as a contributor if you're not already, too.
Oskar Szrajer
@gotar
I put this automaticaly on master branch (for mistake ;P) hope you don't mind
specs do not catch this problem with monitor because non of them use db
Piotr Solnica
@solnic
@gotar well first of all I need to add notifications support to rom, so that we don’t have a monkey patch :)
I’ve got it in a local branch, I’ll push this tomorrow
Tim Riley
@timriley
@gotar oh no worries, master is good. I actually want to add some specs that generate an app and add enough files to set up a persistence layer, just to test that all works properly
Oskar Szrajer
@gotar
now should all works
probably there is not to much users of those skeletons but I use them for every app ;]
Tim Riley
@timriley
😎
Piotr Solnica
@solnic
@flash-gordon so I started working on ASTs for dry-types here dry-rb/dry-types#178
Nikita Shilnikov
@flash-gordon
@solnic yeah, I see what you're doing there 😀
Piotr Solnica
@solnic
@flash-gordon this was my intention from the beginning, I’m pretty sure reducing types into simpler forms will be a great feature useful in many places