These are chat archives for dry-rb/chat

20th
May 2016
Tim Riley
@timriley
May 20 2016 00:10
@jodosha thanks!
Ralf Schmitz Bongiolo
@mrbongiolo
May 20 2016 04:14
@timriley I'm using dry-transaction on master, is it right that the response is something like: Right(Right(#data_here))?
Also, I have to call input.value when passing from one transaction to another, this seems different than the documentations, or did I just missed something?
Ralf Schmitz Bongiolo
@mrbongiolo
May 20 2016 04:20
My bad, the docs on Basic Usage use step, I was trying to use map and try, those doesn't need to call Right or Left explicit
Tim Riley
@timriley
May 20 2016 07:01
@mrbongiolo glad you got it sorted!
Andrew Kozin
@nepalez
May 20 2016 13:30
@backus @flash-gordon I've seen this PR dry-rb/dry-types#70 and wonder, maybe dry-types provides some possibility to build value where missing default keys is allowed?
Andrew Kozin
@nepalez
May 20 2016 14:39

For now I redefine value object locally:

# Base class for value objects
class Value < Dry::Types::Value
  def self.new(value)
    default_hash = schema.keys.each_with_object({}) do |key, hash|
      hash[key] = nil
    end

    super default_hash.merge(value.to_h)
  end
end

but it seems a bit hacky

Damn
Nikita Shilnikov
@flash-gordon
May 20 2016 16:52
@nepalez that's what constructor_type(:schema) does. If you don't use default/maybe types
Ralf Schmitz Bongiolo
@mrbongiolo
May 20 2016 17:32
Is there a way to auto_register multiple classes from a single file with dry-component?
Andrew Kozin
@nepalez
May 20 2016 17:49
@flash-gordon I do use defaults
Nikita Shilnikov
@flash-gordon
May 20 2016 17:51
so you want default values inferred from types or nils?
Andrew Kozin
@nepalez
May 20 2016 17:51
yes
Nikita Shilnikov
@flash-gordon
May 20 2016 17:52
so first or second? :)
Andrew Kozin
@nepalez
May 20 2016 17:53
my solution above infers default values from types and raises if type doesn't allow nil
Nikita Shilnikov
@flash-gordon
May 20 2016 17:53
oh, I see
yeah, I have a PR about it dry-rb/dry-types#71 just don't remeber what @solnic thinks about it :)
Andrew Kozin
@nepalez
May 20 2016 17:58
this method (above) doesn't work in case type allows nil, but expect it to be set explicitly. I'm just ok with this restriction in my current project
still it is not a general solution
Nikita Shilnikov
@flash-gordon
May 20 2016 18:05
@nepalez there is a long discussion related to the issue that ends with nothing dry-rb/dry-types#72 . It seems no one has a perfect solution
at least atm