Hiccdown Development Notes

Showing only those parts of the discussion which lead to #315 and its comments.

See full discussion·See most recent related ideas
  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 12 days ago·#1982
Show idea #330Show idea #3135th of 5 versions leading to #315 (5 total)

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

class ProductsDisplay
  def index vc, # …
    vc.some_helper_method
  end
end

Behind the scenes, the Hiccdown gem would need to make the instance variables available to the display class:

display = @display_module.new

view_context.instance_variables.each do |iv|
  display.instance_variable_set(
    iv,
    view_context.instance_variable_get(iv)
  )
end

Then:

class ProductsDisplay
  def index vc, # …
    vc.some_helper_method(@products)
  end
end
Criticism
Dennis Hackethal’s avatar
Dennis HackethalOP revised about 1 year ago·#317
Show idea #314Show idea #3142nd of 2 versions leading to #315 (2 total)

Then how would you call index from a helper method?

Criticism of #1982Criticized1oustanding criticism
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#315

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

Test this!

Criticism of #315Criticized1oustanding criticism
Dennis Hackethal’s avatar
Dennis HackethalOP revised about 1 year ago·#323

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

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

Not as of #330, they couldn’t.

Criticism of #315Criticized1oustanding criticism
Dennis Hackethal’s avatar
Dennis HackethalOP, about 1 year ago·#341

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

Criticism of #331