F
Florian Weber
hi!
im wondering what is a best practice for some design question i have
right now.
i have a template class, presenting a template in a cms application. the
template has a eruby file, which contain helper methods like
editable_content('some_type', 'some_name')
the helper methods like editable_content are defined in my template
class.
now comes the real question: the helper methods can be used in two
ways creating the objects which represent the editable_content (and
saving
it as a active record) and during the rendering, where the
editable_content
method will fill in the real content.
to me it feels kinda bloated to implement both tasks in one class,
thats why
i would like to extract the rendering part into another class.
whats the best practice for this in ruby?
would i just create something like:
MyRenderingTemplateClass.new(my_template_object).render
basically a decorator, where i also redefine the editable_content method
of the my_template_object, so i can use its normal parsing methods?
thanks a lot for any tip!
ciao!
florian
im wondering what is a best practice for some design question i have
right now.
i have a template class, presenting a template in a cms application. the
template has a eruby file, which contain helper methods like
editable_content('some_type', 'some_name')
the helper methods like editable_content are defined in my template
class.
now comes the real question: the helper methods can be used in two
ways creating the objects which represent the editable_content (and
saving
it as a active record) and during the rendering, where the
editable_content
method will fill in the real content.
to me it feels kinda bloated to implement both tasks in one class,
thats why
i would like to extract the rendering part into another class.
whats the best practice for this in ruby?
would i just create something like:
MyRenderingTemplateClass.new(my_template_object).render
basically a decorator, where i also redefine the editable_content method
of the my_template_object, so i can use its normal parsing methods?
thanks a lot for any tip!
ciao!
florian