by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 31 07:02
    flash-gordon commented #130
  • Jul 31 04:56

    solnic on master

    Merge pull request #131 from da… (compare)

  • Jul 31 04:55

    solnic on release-1.3

    small grammar changes to improv… Merge pull request #131 from da… (compare)

  • Jul 31 04:55
    solnic closed #131
  • Jul 31 04:53

    solnic on release-0.8

    Merge pull request #30 from dav… (compare)

  • Jul 31 04:51

    solnic on master

    Added in missing word and missi… Merge pull request #30 from dav… (compare)

  • Jul 31 04:51
    solnic closed #30
  • Jul 31 04:51
    solnic edited #30
  • Jul 31 00:21
    davich opened #131
  • Jul 31 00:18
  • Jul 31 00:07
    davich opened #30
  • Jul 31 00:03
  • Jul 30 18:27
    Bellatrix988 starred dry-rb/dry-system
  • Jul 30 12:24
    anicholson commented #130
  • Jul 30 12:22
    dry-bot commented #130
  • Jul 30 12:22
    dry-bot commented #130
  • Jul 30 12:21
    anicholson review_requested #130
  • Jul 30 12:19
    anicholson synchronize #130
  • Jul 30 12:14
    anicholson synchronize #130
  • Jul 30 12:02
    dry-bot commented #130
Nikita Shilnikov
@flash-gordon
not really
O(n) max
you can do List.new, it's O(1)
I bet traversing will be way more expensive tbh, it's not omptimized for long lists
otoh, it can be not that bad
Nikita Shilnikov
@flash-gordon
btw, if you use find_in_batches then future_rows.size will be equal total_rows / batch_size
which is better
I think you should give it a chance and see if something can be improved later
Jules Ivanic
@guizmaii
ok thanks for your precise answers ! :)
Jules Ivanic
@guizmaii
This message was deleted
Thanks for your help @flash-gordon ! 🙂
Nikita Shilnikov
@flash-gordon
sure, np
Grant Shangreaux
@gcentauri
is it counterproductive to add methods to structs? i'm primarily thinking of predicate type methods that would only return true or false based on the data the struct is holding
like, if i had a struct Fruit and if its name field was "banana" then my_fruit.banana? would return true. or... should there be helper functions like is_banana?(fruit)
Nikita Shilnikov
@flash-gordon
I do have a few methods like this, don't see anything harmful since it's not the same as having an AR-model :)
Grant Shangreaux
@gcentauri
haha thanks
ruby often feels like a slippery slope to me in those regards
Jules Ivanic
@guizmaii

Hi everyone,

I’m using the Task monad and I saw that there’s a pure function but there’s not its “dual” failed (equivalent of Concurent::Promise.reject).

How would you implement it ?

I don’t want to throw exception. Just create an immedialty failed Task
(throwing is expensive in JRuby)

is this something sensible:

    def failed(error)
      Dry::Monads::Task.new(Concurrent::Promise.reject(error))
    end

???

This message was deleted
Nikita Shilnikov
@flash-gordon
@guizmaii yeah, we should have it, no particular reason we don't have, just no one asked for it
Jules Ivanic
@guizmaii
If I have time I’ll push you a PR
Nikita Shilnikov
@flash-gordon
:+1:
Jules Ivanic
@guizmaii
def failed(error, &block) signature looks ok for you ? With the same Undefined trick as in pure ?
Nikita Shilnikov
@flash-gordon
not sure because answering this question would pre-emptying my current brain stack :)
Jules Ivanic
@guizmaii
k. We’ll talk about that around a good old PR so
:)
Tonni Tølbøll Lund Aagesen
@ta
Hello, How do I get transform_keys(&:to_sym) to work with nested structs? It works fine with 1st level attributes.
Nikita Shilnikov
@flash-gordon
create and use the same base class across your structs
Tonni Tølbøll Lund Aagesen
@ta
Nikita Shilnikov
@flash-gordon
similar but I think you want to nested structs rather nested schemas
class MyStruct < Base
  attribute :id, Types::Strict::Integer
  attribute :data do
    attribute :code, Types::Strict::Integer.optional.default(nil)
    attribute :msg,  Types::String.optional.default(nil)
  end
end
like that^
Tonni Tølbøll Lund Aagesen
@ta
MyStruct.new({"id" => 1, "data" => { "code" => 200 }}) still doesn't set the code attribute :/
Nikita Shilnikov
@flash-gordon
lemme look into this
Tonni Tølbøll Lund Aagesen
@ta
but thanks for the nested structs hint :)
cool
Nikita Shilnikov
@flash-gordon
change, attribute :data do to attribute(:data, Base) do
because it's not usign Base as default there but Dry::Struct
Tonni Tølbøll Lund Aagesen
@ta
yes, was about to write that solution :)
can there be an argument for having nested structs inherit from parent struct?
Nikita Shilnikov
@flash-gordon
we could have a means for that
I'm not sure what's the best here but having something would be nice
I came across this pattern a copule of times
Tonni Tølbøll Lund Aagesen
@ta
Thanks for helping out
oh btw, can a nested struct be optional like a nested schema?
Nikita Shilnikov
@flash-gordon
you mean absence of key or nil as a value?
Tonni Tølbøll Lund Aagesen
@ta
I have Types::Hash.schema( ... ).optional.default(nil) in some structs