Question about a couple of methods that I saw in this tutorial: https://richonrails.com/articles/rails-presenters
In particular:
module ApplicationHelper
def present(model, presenter_class=nil)
klass = presenter_class || "#{model.class}Presenter".constantize
presenter = klass.new(model, self)
yield(presenter) if block_given?
end
end
And
class BasePresenter < SimpleDelegator
def initialize(model, view)
@model, @view = model, view
super(@model)
end
def h
@view
end
end
How does the present
method work? I'm pretty confused about its arguments parameters, ie, model, presenter_class=nil
along with the whole method.
And I'm also very confused about model, view
arguments as well, and where/what is super(@model)
method?
Any information that can explain those methods would be so immensely helpful because I've been staring at it for the past while wondering how the heck they work.