Hiccdown Development Notes

See full discussion
  Log in or sign up to participate in this discussion.
With an account, you can revise, criticize, and comment on ideas.

Discussions can branch out indefinitely. Zoom out for the bird’s-eye view.
Dennis Hackethal’s avatar
Dennis HackethalOP revised about 1 year ago·#325·· Collapse

Hiccdown methods should live in their own, separate modules. How about they are called ‘displays’?

module ProductsDisplay
  def self.index vc, # …
    vc.some_helper_method
  end
end

A benefit of this approach is that, when people start a new Rails app, they may end up putting whatever they’d otherwise put in a helper in a display, since displays have the benefit of having unambiguously resolvable method names.

3rd of 4 versions ·Criticized2 criticim(s)
Dennis Hackethal’s avatar
Dennis HackethalOP revised about 1 year ago·#317·· Collapse

Then how would you call index from a helper method?

2nd of 2 versions ·Criticism of #325Criticized1 criticim(s)
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#315·· Collapse

I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)

Criticism of #317
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#321·· Collapse

Test this!

Criticism of #315Criticized1 criticim(s)
Dennis Hackethal’s avatar
Dennis HackethalOP revised about 1 year ago·#323·· Collapse

Tested, it works. self does indeed point to the view_context in the helper. Verified by printing object_ids.

2nd of 2 versions ·Criticism of #321
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#331·· Collapse

Not as of #330, they couldn’t.

Criticism of #315Criticized1 criticim(s)
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#341·· Collapse

It doesn’t really matter. This would be like calling a controller action from a helper method. Not something people do.

Criticism of #331
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#326·· Collapse

I’m trying this now. Having to prepend every invocation of a helper method with vc. is getting really old really fast.

Criticism of #325
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#327·· Collapse

Instance variables are not available inside the methods.

Criticism of #325
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#328·· Collapse

They are: vc.instance_variable_get(:@foo)

Criticism of #327Criticized1 criticim(s)
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#329·· Collapse

That’s way too verbose.

Criticism of #328