These are chat archives for dry-rb/chat

19th
Apr 2016
Tim Riley
@timriley
Apr 19 2016 05:31
Published the next in my “convince everyone to Ruby the dry-rb way” series: http://icelab.com.au/articles/inactive-records-the-value-objects-your-app-deserves/
Tim Cooper
@coop
Apr 19 2016 05:41
s/Upboat/Upvote/
I think I prefer upboat.
Tim Riley
@timriley
Apr 19 2016 05:41
aww, where’s the fun in that? ;)
Benjamin Klotz
@tak1n
Apr 19 2016 05:43
@timriley awesome post, also upboated it ;) :D
Tim Riley
@timriley
Apr 19 2016 05:43
Thanks! In 8 more post’s time, maybe I’ll be ready to introduce an actual app structure, haha
Benjamin Klotz
@tak1n
Apr 19 2016 05:44
I'm waiting for it :P
Actually what's the plan with dry-web?
Any help needed to make progress?
Tim Cooper
@coop
Apr 19 2016 05:45
I also think it was a good read :)
Tim Riley
@timriley
Apr 19 2016 05:46
I’ll make a release this week, just so it’s out on rubygems. There’s plenty we could do with it, I think it might be good if we could get a bunch of things listed out into GH issues. Might need to wait for solnic to get back for some of that to happen. But I might start noting down some things when I get a chance :)
Benjamin Klotz
@tak1n
Apr 19 2016 05:47
Okay, cool just ping me if you have smth I can help with :)
Tim Riley
@timriley
Apr 19 2016 05:47
Awesome, will do.
dan-klasson
@dan-klasson
Apr 19 2016 06:56
```
    def key(name, &block)
      ::Kernel.warn 'key is deprecated - use required instead.'

      required(name, &block)
    end
docs are not updated?
Tim Riley
@timriley
Apr 19 2016 06:57
@dan-klasson this isn’t released as a gem version yet
We have doc updates waiting on the releases.
dan-klasson
@dan-klasson
Apr 19 2016 06:57
@timriley cool, thx
Tim Riley
@timriley
Apr 19 2016 06:57
No probs!
dan-klasson
@dan-klasson
Apr 19 2016 07:02
@timriley is master stable? is it safe to use?
Tim Riley
@timriley
Apr 19 2016 07:02
I reckon so
Of course, you take a risk whenever you use master of anything, but AFAIK it’s fine here :)
panigrah
@panigrah
Apr 19 2016 07:04

@timriley the following doesn't work on master any more. fails with a NoMethodError for 'key'

 require 'dry-validation'
 class Schema < Dry::Validation::Schema::Form
      key(:email) { |email| email.filled? }
  end

did the API change?

Tim Riley
@timriley
Apr 19 2016 07:04
Yeah, it did.
required(:email).filled is whart you want now
dry-rb/dry-validation#99 is a decent summary
David Strauß
@stravid
Apr 19 2016 07:14
@timriley upboated! Please keep writing them :)
Benjamin Klotz
@tak1n
Apr 19 2016 08:04
ugh dry-rb/dry-types#78 :(
panigrah
@panigrah
Apr 19 2016 08:57
@timriley In master - I also cannot extend Dry::Validation::Schema::Form as described in documentation - is that intentional? See my excerpt above. Thanks
Hannes Nevalainen
@kwando
Apr 19 2016 08:58
@panigrah
Dry::Validation.Form{
  key(:email) { |email| email.filled? }
}
New syntax
panigrah
@panigrah
Apr 19 2016 08:59
Thanks @kwando I wanted to know if the old syntax is supported or retired. Guessing it is retired
Hannes Nevalainen
@kwando
Apr 19 2016 08:59
Yeah, it is retired =)
Tim Cooper
@coop
Apr 19 2016 09:05
I wonder if it is worth adding a caluse to the README explaining that these docs are for master - checkout the appropiate release for the relevant docs.
I’m sure I’ve seen other projects do that.
Hannes Nevalainen
@kwando
Apr 19 2016 09:05
:thumbsup: for that
dan-klasson
@dan-klasson
Apr 19 2016 09:07
@coop actually the docs is for the latest release, not master
Tim Cooper
@coop
Apr 19 2016 09:07
@dan-klasson the docs on the website are but I said README.md.
dan-klasson
@dan-klasson
Apr 19 2016 09:08
@coop but there is nothing in the README
Tim Cooper
@coop
Apr 19 2016 09:08

@dan-klasson

I wonder if it is worth adding a caluse to the README explaining ...

dan-klasson
@dan-klasson
Apr 19 2016 09:08
... that these docs are for maste
r
Tim Cooper
@coop
Apr 19 2016 09:10
Right, I feel like I wasn’t clear, I meant the docs in the README.
dan-klasson
@dan-klasson
Apr 19 2016 09:10
hehe, but there are no docs in the README. that's why i'm totally confused right now :)
Fran Worley
@fran-worley
Apr 19 2016 09:12
What would be amazing is to be able to view the docs on the website by release
Tim Cooper
@coop
Apr 19 2016 09:12
That makes sense becauase the docs will only reference the current released version.
@fran-worley I believe Bundler does that.
Fran Worley
@fran-worley
Apr 19 2016 09:12
I mean the dry-rb.org site
Tim Cooper
@coop
Apr 19 2016 09:13
I know - I’m saying that bundler does something similar.
Fran Worley
@fran-worley
Apr 19 2016 09:14
Ah didn't know that.
It might solve a lot of the syntax changing queries if people could view the docs on the site by version vs Master. e.g. http://dry-rb.org/gems/dry-validation/v-0.7.4
Tim Cooper
@coop
Apr 19 2016 09:16
I like it.
Bundler just copy over the docs for each release - https://github.com/bundler/bundler-site/tree/master/source
Fran Worley
@fran-worley
Apr 19 2016 09:17
Yeah, I'm talking about taking what is on the dry-rb site rather than the readme/docs for the repo itself
that way when versions get bumped and the docs/ examples on the site are changed those running old versions don't miss out
Tim Cooper
@coop
Apr 19 2016 09:19
I totally get what you mean, I’m just linking to how bundler is doing it. Their docs site is generated from https://github.com/bundler/bundler-site. The dry-rb.org docs site is generated from https://github.com/dry-rb/dry-rb.org/.
Fran Worley
@fran-worley
Apr 19 2016 09:19
Sorry, my brain is not engaging... I know understand what you mean!
I thought you meant that bundler does some magic with rubygem docs for versions... must get a :coffee: before I do anything else!
Tim Cooper
@coop
Apr 19 2016 09:20
:P
Tim Cooper
@coop
Apr 19 2016 22:30

@timriley I’ve been reading over your article again and I have a feeling that you meant to say that an Article is an entity not a value object. From your article you quote the definition of a value object as:

A value object is one whose notion of equality is based on the values of the attributes it contains, not its object identity.

I agree with this but your article class includes an id field:

class Article < Dry::Types::Struct
  attribute :id, Types::Strict::Int
  attribute :title, Types::Strict::String
  attribute :body, Types::Strict::String
end

I think we both will agree that Article.new(id: 1, title: “title”, body: “body”) != Article.new(id: 1, title: “amended title”, body: “body”) in code land but in the real world the objects are the same, they’re both referring to the exact same article (the second article is modified and therefore its title is different).

IMO a value object is something that is only identifiable by its attributes, things like money, name, address and credit cards.

I did enjoy the article though, just my 2 cents.

Simon Schmid
@sled
Apr 19 2016 22:31
@coop :+1:
Tim Riley
@timriley
Apr 19 2016 22:31
Good point, @coop. id being there is kind of a smell that it’s not a true value object.
Simon Schmid
@sled
Apr 19 2016 22:31
but it leaves me wondering how to handle objects which could be in an invalid state :)
Tim Riley
@timriley
Apr 19 2016 22:31
Even though the the equality methods on Dry::Types::Struct still take into account all the attributes.
@sled we just treat invalid data as just that - a hash of invalid params/attributes
pass it around until like that the user can make it valid
Simon Schmid
@sled
Apr 19 2016 22:34
@timriley what do you think about an anonymous class which represents the hash as simple struct with attr_readers ?
kind of a "representer" of the invalid data
Tim Riley
@timriley
Apr 19 2016 22:34
What does that get you over a hash?
Simon Schmid
@sled
Apr 19 2016 22:35
@timriley compatibility with existing libraries which can't handle hashes directly
Tim Riley
@timriley
Apr 19 2016 22:35
heh. Well I guess that’d be helpful then :)
Simon Schmid
@sled
Apr 19 2016 22:36
mh or maybe a simple decorator which just delegates to the fetch method
Tim Cooper
@coop
Apr 19 2016 22:36
http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215 - if you haven’t read this I would strongly recommend reading through it. A lot of the dry / rom stuff talks about building domain orientated systems, this book was the original instigator (I believe).
Tim Riley
@timriley
Apr 19 2016 22:36
Cool, thanks for the recommendation @coop
Simon Schmid
@sled
Apr 19 2016 22:36
thanks! :)
Tim Cooper
@coop
Apr 19 2016 22:37
I actually have a copy you could borrow next time you’re in Brisbane :P
Tim Riley
@timriley
Apr 19 2016 22:37
hehe
Tim Riley
@timriley
Apr 19 2016 22:54
@nepalez Congrats on the first dry-initializer release :) Would you like to pen a little blog post for the dry-rb site announcing it?
Tim Riley
@timriley
Apr 19 2016 22:59
@coop thinking I could maybe add a little parenthetical aside explaining the difference between entities and value objects – do you reckon that’d help?
Tim Cooper
@coop
Apr 19 2016 23:10
I think it would help.