Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 21:12
    D1mon starred dry-rb/dry-matcher
  • 15:44
    graudeejs starred dry-rb/dry-container
  • 08:41
    esparta commented #366
  • 08:39
    flash-gordon commented #366
  • 08:39

    flash-gordon on master

    Fix error on Dry::Types::Array#… Merge pull request #366 from es… (compare)

  • 08:39
    flash-gordon closed #366
  • 08:38
    flash-gordon closed #362
  • 08:38
    flash-gordon commented #362
  • 08:37
    flash-gordon closed #361
  • 08:37
    flash-gordon commented #361
  • 07:48

    solnic on master

    Adding missing built-in predica… Merge pull request #65 from esp… Merge branch 'release-1.0' (compare)

  • 07:47

    solnic on release-1.0

    Adding missing built-in predica… Merge pull request #65 from esp… (compare)

  • 07:47
    solnic closed #65
  • 07:29
    esparta opened #65
  • 07:06
  • 06:23
    robturtle starred dry-rb/dry-monads
  • 05:15
    Travis esparta/dry-types (array_try_specs) passed (4)
  • 05:12
    esparta opened #366
  • Oct 21 20:38
    patrickclery commented #361
  • Oct 21 19:47
    samdindyal starred dry-rb/dry-container
Simon Schmid
@sled
yes but this seems broken
just read the conversation here in gitter
Piotr Solnica
@solnic
ah damn
Simon Schmid
@sled
yep, not the first time rails breaks my balls ;)
I think the issue is the "registry" of the container is not re-loaded properly
Piotr Solnica
@solnic
could be it
I don’t use rails at the moment so I’m not looking into it
Simon Schmid
@sled
sure I'm trying to fix it on my own
after reloading it tells me Dry::Container::Error: There is already an item registered with the key "customer.types.address"
Andy Holland
@AMHOL
@sled can you post your dry-types related code in a gist?
Simon Schmid
@sled
@AMHOL uhm for the reloading?
Andy Holland
@AMHOL
Nah just interested in how you're using it

I think calling

module Types
  include Dry::Types.module
end

in an initializer

Then defining your custom types somewhere in the app/lib directory should stop the problem from happening
Simon Schmid
@sled
I'll try right away :)
I also noticed there are no setters, do you have any best practices on how to modify certain attributes easily?
the one I came up with is Hypo::Types::Location.new(original.to_h.merge(phone_number: '123456'))
Andy Holland
@AMHOL
Yeah, mutable structs won't be added to dry-types core
Piotr Solnica
@solnic
we deliberately fight with mutability
(so dramatic)
Simon Schmid
@sled
@solnic, I totally support that - however it's still nice to have an easy way of creating a copy with the modifications
might be a cool case for keyword arguments
Simon Schmid
@sled
@AMHOL just tried with the initializer and putting custom types into app/lib, however if I auto-load these paths it fails with the same error
Andy Holland
@AMHOL
Ahh shit, yeah
Forgot types get registered automatically when you inherit from Struct
Simon Schmid
@sled
yep I think I need to "reset" the container's registry somehow
Piotr Solnica
@solnic
Screen Shot 2016-04-12 at 16.10.02.png
related ^^
that’s from Programming Clojure book but it’s a universal truth
Dung Nguyen
@mmeeoorroo
I have Product and Category, both are Types::Struct
Product has a field with Category type. How can we make that field nullable so that I don't have to join/query categories table?
Simon Schmid
@sled
attribute :category, Category.optional :D
just learned today
Dung Nguyen
@mmeeoorroo
thanks but I get error 'NoMethodError: undefined method `optional' for Category:Class' :D
Simon Schmid
@sled
is your category a type?
Dung Nguyen
@mmeeoorroo
class Category < Dry::Types::Struct; end
class Product < Dry::Types::Struct
attribute :category, Category.optional
end
is that correct?
Simon Schmid
@sled
mh... another guess: attribute :category, Types::Strict::Nil | Category
(I'm still learning too)
Dung Nguyen
@mmeeoorroo
still not work, I will learn more :D
thanks @sled
Simon Schmid
@sled
@mmeeoorroo actually the one with | works for me
ah nope
Dung Nguyen
@mmeeoorroo
the | works with this trick: Product.new({id: 1}.merge(category: nil))
Piotr Solnica
@solnic
@sled I use separate struct classes, one with a category and one w/o a category
Dung Nguyen
@mmeeoorroo
magic :D
Piotr Solnica
@solnic
a product with category would be a separate concept in my app
vs a product w/o a category