Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 10 23:46
    johnmaxwell commented #116
  • Dec 10 21:54

    flash-gordon on master

    Halt with mutable backtrace Ex… Merge pull request #116 from jo… (compare)

  • Dec 10 21:54
    flash-gordon closed #116
  • Dec 10 21:54
    flash-gordon commented #116
  • Dec 10 21:49
    johnmaxwell commented #116
  • Dec 10 21:47
    johnmaxwell commented #116
  • Dec 10 21:43
    johnmaxwell commented #116
  • Dec 10 21:39
    johnmaxwell commented #116
  • Dec 10 21:31
    johnmaxwell commented #116
  • Dec 10 21:22
    flash-gordon commented #116
  • Dec 10 19:41
    johnmaxwell opened #116
  • Dec 10 19:36
  • Dec 10 10:24
    krautcat starred dry-rb/dry-view
  • Dec 10 10:24
    krautcat starred dry-rb/dry-types
  • Dec 10 10:24
    krautcat starred dry-rb/dry-system
  • Dec 10 10:24
    krautcat starred dry-rb/dry-monads
  • Dec 10 06:55
    IgrekYY starred dry-rb/dry-initializer
  • Dec 09 18:02
    ekremkaraca starred dry-rb/dry-system
  • Dec 09 11:13
    dilcom commented #375
  • Dec 09 10:29
    flash-gordon commented #375
Nick Sutterer
@apotonick
:D
Tim Riley
@timriley
oh what?
oh, .call(foo, bar) effectively goes .new(something_here_maybe).call(foo, bar) or something?
Nick Sutterer
@apotonick
.call(foo, bar) would do .new(foo, bar).call(foo, bar) i guess
simply passes it to both methods
Tim Riley
@timriley
why would you want it going to both?
Nick Sutterer
@apotonick
because in new, the polymorphic builder is called and the programmer might need arbitrary data to decide what to build
actually... not sure if we'd need bar in call, you're very right
the API has been around for 2 years now, all i want is to make it work with auto_inject/initialize so we can hook our objects into dry and vice-versa
Tim Riley
@timriley
anyway, so this sounds like it actually just a case of constructor dependency injection after all
so you probably want some variation of the Kwargs strategy (https://github.com/dry-rb/dry-auto_inject/blob/master/lib/dry/auto_inject/strategies/kwargs.rb)
Nick Sutterer
@apotonick
"variation"?
Tim Riley
@timriley
except you’d look for the kwargs on the second arg
and you’d just pass through/assign the first arg, your “params”
Nick Sutterer
@apotonick
i'll have a look, going on a trip now. thanks for your help brother
Tim Riley
@timriley
:+1:
Alternatively, you could just give your params a “special” arg name
e.g. params: and then just go kwargs for everything
Tim Riley
@timriley
params would be in that case a “dependency” that must always be provided manually, rather than looked up by any auto-injection system
I’m not sure if that feels good or not, though
heh
Nikita Shilnikov
@flash-gordon
@backus sure man, no problem. I was actually about it, but then I dug a bit deeper and found there was no spec for callable defaults so considered this behavior as a bug/overlook. So if you have any strong dependencies on some behavior, be sure it's covered with specs. Anyway, I'll cc you next time in any case :)
John Backus
@backus
Thanks
Yeah I'm not too worried and I think I specified our needed behavior pretty closely
Nick Sutterer
@apotonick
@timriley i have the :params kw name ATM but it .. sucks. it feels too clumsy
Andrew Kozin
@nepalez
@jmgarnier if you're planning heavily use reader: :private as a pattern, then you would like new using method in dry-initializer:
https://github.com/dry-rb/dry-initializer/releases/tag/v0.7.0
Jean-Michel Garnier
@jmgarnier
Thanks @nepalez Things move very fast in dry-rb word, thank you for the notification :)
Tom Willis
@twillis

Hey all, was upgrading to the 0.10 series from the 0.9 series and I'm getting errors in the schemas that use rules with custom predicates...

"ArgumentError: unique_npi_number? predicate arity is invalid"

    configure do
      def unique_npi_number?(id, org_uid, npi_number)
        return true if npi_number.nil?
        existing_provider = Provider.find(org_uid: org_uid, npi_number: npi_number)
        if existing_provider && existing_provider[:provider_uid] != id
          false
        else
          true
        end
      end
    end

   ...

    rule(unique_npi_number: [:id, :org_uid, :npi_number]) do |id, org_uid, npi_number|
      npi_number.unique_npi_number?(npi_number, org_uid, id)
    end

was working just fine on the 0.9 series

Christopher Dennl-Ortega Arrieta
@cdennl
@twillis you can now define arbitrary validation rules, check the changelog on 0.10. some stuff changed
@twillis and you put in 4 arguments to a predicate which takes 3
@twillis you can omit the npi_number argument at the function call
npi_number.unique_npi_number?(org_uid, id) should do the trick
Tom Willis
@twillis
ah ok I'll check the change log, i'd rather re-write the stuff if it's a cleaner syntax than the above. thanks so much @cdennl
Ricardo Bernardeli
@bernardeli
Hi guys! Hope you're all well. Playing with dry-struct and dry-types, and wanted to have an array with members of two types, where both types have same attribute BUT different type. Example below:
require "dry-struct"
require "dry-types"

module Types
  include Dry::Types.module
end

class Answer < Dry::Struct
  attribute :question_id, Types::String

  class Select < self
    attribute :value, Types::Hash.schema(id: Types::Int)
  end

  class Text < self
    attribute :value, Types::String
  end
end

class Survey < Dry::Struct
  attribute :answers, Types::Array.member(Answer::Text | Answer::Select)
end

Survey.new(
  answers: [
    Answer::Select.new(question_id: 1, value: {id: 10}),
    Answer::Text.new(question_id: 1, value: "foo")
  ]
)

#<Survey answers=[#<Answer::Text question_id=1 value={:id=>10}>, #<Answer::Text question_id=1 value="foo">]>
Problem here is, both answers came back as Answer::Text.
If I invert the order of the members to .member(Answer::Select | Answer::Text), things blow up.
The other thing I tried too is to have .member(Answer) since Select and Text are subclasses of Answer.
It doesn't blow up but turns Answer::Select into an Answer, getting rid of attribute :value.
Ricardo Bernardeli
@bernardeli
How can I achieve members of an array to accepting subclasses of a type?
Appreciate if someone can shed some light for me! :)
Tim Riley
@timriley
If you could both post these up to https://discuss.dry-rb.org, we’ll see if we can get some answers for you - this is where we’re trying to handle support questions like this.
Ricardo Bernardeli
@bernardeli
Cool - will do!
Thanks Tim!
Tim Riley
@timriley
:pray:
Nick Sutterer
@apotonick
hey @timriley i have a question about dry-auto_inject (again), because i decided we're not using dry-initializer (we don't need coercion, types, etc. at this point), but we simply have two arguments initialize(params, options) where options are all the dependencies injected
now i have two things
  1. how would i extend Ai to "eat" the two-arg version params, options? (i think you hinted this twice already)
  2. can we change Ai to not add any readers but only merge the auto-injected parameters into the options hash? that would all happen on the class-level
Nick Sutterer
@apotonick
@timriley i see that i might have to write my own strategy. fine with that, but you gotta help me!!! :tea:
Yurii Danyliak
@yuriidanyliak
Hey guys! Just a quick question: is there some ability to use dry-validation output with form_for or deliver the results of validation to front-end in some elegant way?
Nick Sutterer
@apotonick
@yuriidanyliak yes, with reform!
Yurii Danyliak
@yuriidanyliak
Hello @apotonick ! Yes, already read about reform-rails. Is there any way to use schema output with reform?