Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 07:54
    flash-gordon commented #115
  • 05:40
    wpzero starred dry-rb/dry-monads
  • 05:30
    dilcom opened #375
  • 02:18
    johnmaxwell edited #115
  • 02:18
    johnmaxwell edited #115
  • Dec 08 23:10
    johnmaxwell labeled #115
  • Dec 08 23:10
    johnmaxwell opened #115
  • Dec 07 14:03

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 10:01
    Travis dry-rb/dry-view (master) errored (636)
  • Dec 07 09:58
    Travis dry-rb/dry-view (master) errored (635)
  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

Simon Schmid
@sled
cool! :)
Piotr Solnica
@solnic
it’s basically Types::Strict::Nil | Types::Int
Simon Schmid
@sled
I'm really enjoying the dry-rb repository :)
Piotr Solnica
@solnic
awesome :)
Simon Schmid
@sled
have you ever tried to mixin schemas? :)
Like class House < Dry::Types::Struct; include Addressable; .... end
Piotr Solnica
@solnic
nope, I don’t use mixins in structs at all
Simon Schmid
@sled
how do you handle commonly repeating subsets of fields then? :)
Piotr Solnica
@solnic
class inheritance
Simon Schmid
@sled
are incomplete types possible e.g if I set some attributes as optional with a default, do I have to pass the key in the initializer e.g ModelType.new({optional_field: nil}) vs ModelType.new
Piotr Solnica
@solnic
@sled it’s being discussed how structs should work wrt optional attrs dry-rb/dry-types#72
currently you need constructor_type(:schema) to be set for optional types with default values to be set when sth is missing
Simon Schmid
@sled
thx! now I just have to bend rails to re-load my types correctly :D
Piotr Solnica
@solnic
@sled see dry-types-rails
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?