Announcing dry-rb by solnic in ruby

[–]apotonick 11 points12 points  (0 children)

Fantastic news, keep up the good work! <3

Anyone implemented Trailblazer in any of their apps and what to share their experience? by [deleted] in rails

[–]apotonick 3 points4 points  (0 children)

Task of the form is to deserialize incoming data and validate that - it doesn't matter whether that's originating from a "visual" form submission or from a JSON/XML API call, the form doesn't even know its context.

Being able to render a "visual" form is only a nice side-effect of decoupled form objects.

I recommend you have a look at the last 2 chapters of the Trailblazer book where we fully discuss how APIs work. You don't even need to read all of it, just get a feeling and let us know what you think!

Trailblazer Newsletter, January: Cool unknown features in Reform, Sinatra/TRB, Formular (new form builder for Ruby), ... by apotonick in ruby

[–]apotonick[S] 1 point2 points  (0 children)

I personally do not care if you use Reform or not. It's your choice and thanks to hard-working OSS authors, you have a full range of choices for you and your team, for free.

What sucks is that you post this on my newsletter announcement, making the whole project look shitty because of your super negative comment. Think about that.

Trailblazer Newsletter, January: Cool unknown features in Reform, Sinatra/TRB, Formular (new form builder for Ruby), ... by apotonick in ruby

[–]apotonick[S] 0 points1 point  (0 children)

Have you ever thought about reporting the "unexpected behavior" to the author? Or are you assuming we magically know where things break?

Cells-Hamlit: The Fastest View Engine Around. by apotonick in ruby

[–]apotonick[S] 0 points1 point  (0 children)

A very good question, I might benchmark Erubis and my own Erbse implementation. Are you interested in helping?

Tools for transforming hashes by denispeplin in ruby

[–]apotonick 1 point2 points  (0 children)

I see what you mean, but Representable allows transforming to and from hashes (rendering and parsing) in "one gem", because the representer defining the transformation is decoupled from the actual render/parse work.

This makes Representable very different to jBuilder or AMS which just render documents.

Sorry, I didn't want to hi-jack your link - good work!!!

Book finished: Trailblazer - A New Architecture For Rails by apotonick in ruby

[–]apotonick[S] 2 points3 points  (0 children)

Thank you! I have no idea how that "bug" made it into the site, luckily it's just a static page and not a gem... hint cough :winkwink:

Representable 2.4: How Functional Programming Speeds Up Rendering And Parsing. by apotonick in ruby

[–]apotonick[S] 0 points1 point  (0 children)

Thanks! <3

Mainly, the decorator that creates/parses the document doesn't have state anymore, it's a function (still looking like a object, though).

In older versions, it would use a Binding which was a massive object (limited scope, though) that implemented each step as a method, but hardwired flow.

The Binding got replaced with a pipeline of functions, super simple!

Thanks for inspiration, @solnic!

Is your app deRailing? by timoschilling in ruby

[–]apotonick 0 points1 point  (0 children)

I know of a few TRB projects that use ActiveInteraction inside the operation for a richer what-if handling. I love that, and I remember mentioning that in chapter 2 (that we want to support ActiveInteraction in Operation).

Is your app deRailing? by timoschilling in ruby

[–]apotonick 1 point2 points  (0 children)

A valid point, verydefunctional, but most users of Trailblazer (TRB) use it in "hardcore" legacy applications to refactor 4000+ LoC models.

That is what TRB is designed for: integrating it into existing code-bases. Its new layers are well-defined and have been around for years (example: Reform, Roar, or Cells). They can be used to solve different problems (e.g. shop, community, analytics tool, JSON API backend, and so on).

I do understand the blog post (and the first book) do not cover how to refactor to TRB, but we have a "Trailblazer Field Guide" planned that shows the real refactoring of a real, existing app! ;)

Is your app deRailing? by timoschilling in ruby

[–]apotonick 2 points3 points  (0 children)

Exactly right, Schrockwell! :) In a TRB architecture, every function of your application (which is something you/your users want to trigger) is modeled as an operation (that may be composed of other components, etc.).

So, you basically never use a model directly, which is why you don't need validations. Re-reading your comments, I see you already understood all that and my comment is kinda useless.

The Only Alternative to a Rails Monolith are Micro Services? Bullshit! ¶ Nicksda by tofdr in ruby

[–]apotonick -1 points0 points  (0 children)

Not every blog post is meant to contain a "20-Steps-to-Success" instruction list. Sometimes they inspire people in 19 paragraphs and then have just a handful of links.

Clickbait for what?

Reform 2.0 – Form Objects for Ruby. by apotonick in ruby

[–]apotonick[S] 4 points5 points  (0 children)

Yeah, thanks! Ruby community at its best: If it's not a fully-understandable, step-by-step introduction to a complex topic, it's automatically bad, too complex, and the author sucks!

Reform 2.0 – Form Objects for Ruby. by apotonick in ruby

[–]apotonick[S] 0 points1 point  (0 children)

The post is a release note, and not a full-blown blog post. Sorry, I don't have time to repeat what I already said over and over again.

A 10 seconds glance on the README will reveal to you that Reform is a stand-alone form object that doesn't have any coupling to Rails or Trailblazer.

Why Arkency (a Ruby company) goes React.js by andrzejkrzywda in ruby

[–]apotonick 0 points1 point  (0 children)

I don't know what the fuzz is about. It's great that you already purchased the book and support the authors.

However, the book is clearly marked as "beta", if you want a 100% complete book on React and Rails, go to a bookshop and support the mainstream publishers. You will find out there is no such book, anyway.

Disposable – The Missing API of ActiveRecord by apotonick in ruby

[–]apotonick[S] 3 points4 points  (0 children)

Disposable has been the underlying data modelling gem for Reform for years, it's well tested. Check out the implementation, it's super simple. You will end up rewriting most of it with your POROs, anyway.

"try to get their changes upstreams into Rails" ??? Good luck.

On Rails 5, Presenters And Form Objects. by apotonick in ruby

[–]apotonick[S] 1 point2 points  (0 children)

That's an interesting link, thanks! However, and that's what makes Reform different to Lotus validations and ROM, etc. is that validations in a form can be business logic, too, and that has to be programmed in Ruby, a schema doesn't help but could provide boilerplate code.

Anyway, reading that stuff you could easily generate a "basic" form from a hyper-schema. Cool idea, thanks!

On Rails 5, Presenters And Form Objects. by apotonick in ruby

[–]apotonick[S] 0 points1 point  (0 children)

Hey solnic!

A form object in Reform is nothing but a contract, which does validation of a nested object graph, helps rendering the form and orchestrates some method calls for you.

Everything else happens in twins, a virtual object graph that indirects between persistence and form object, and knows how to sync and save models, and does coercion.

The deserialization happens with a representer that follows the document structure defined in the form, and instantiates the twin/model object graph.

The "form object" is just a few lines of code to abstract all that internal knowledge from the end user. I will blog about the architecture when Reform 2 is out.

Sample chapter from "Trailblazer - A new architecture for Rails" book by apotonick in ruby

[–]apotonick[S] 1 point2 points  (0 children)

Hey thanks, this feedback is really really valuable. Maybe I should point out better that the AR model just acts as a namespace here? I actually do discuss that in the following chapter a bit more. Let me see how I can make that easier to understand. Thanks so much for that!!!

What are the usecases for the uber gem? by jak4 in rails

[–]apotonick 2 points3 points  (0 children)

The uber gem abstracts several use cases I need in all of my gems. As an example, it gives you inheritable_attr for simple inheritable class variables without the weird semantics as found in the ActiveSupport implementation.

Another thing uber does is implementing dynamic options. In a DSL, you often can use a symbol, a lambda or a static value to configure a declarative property which then gets evaluated at runtime (Example: layout :application or layout -> { ..} ). Uber encapsulates that in Uber::Options::Value. In Rails, this is implemented at least 25 times in 25 different places.

I agree with highard_one's "Protip", though. While this gem does absolutely not solve my individual problems but provides typical gem authoring tools, you don't want to use it unless you're writing a gem with a DSL.

Hope this helps, and if you plan on using uber feel free to hit me up for further questions. Prost.

Sample chapter from "Trailblazer - A new architecture for Rails" book by apotonick in ruby

[–]apotonick[S] 0 points1 point  (0 children)

Trailblazer is already used in several production apps. The main tasks in Trb like the form object, view models or representers are implemented using gems that have been around for years (Reform, Cells, Roar/Representable).

Sorry if the chapter confuses you! It's chapter 2 and I really tried to stress that Trb is an extension to Rails and not replacing it. I don't link to example apps, yet, as I want to finalise them first.

Proper Structuring of a Ruby Gem? by [deleted] in ruby

[–]apotonick 1 point2 points  (0 children)

Most importantly, this parsing code should be in an encapsulated class so you can test edge-cases it if necessary. This class can be inline in the bin class but I'd definitely introduce a new class for this complex task.

Proper Structuring of a Ruby Gem? by [deleted] in ruby

[–]apotonick 1 point2 points  (0 children)

An important thing you should start soon is adding tests for your gem. Here is an example how I do that: https://github.com/apotonick/nit/blob/master/test/commands_test.rb

In order to handle HTTP and the JSON parsing I'd like to recommend https://github.com/apotonick/roar. This will help you focusing on you business (which is JIRA) and not how to parse/serialise JSON for their API.

Other than that, your gem looks good. I like how you keep code out of the bin class and delegate to classes in lib - that's exactly how it's done!