-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hello.
I use Toys::Template. It's a good way to create gems with a set of toys tools which can be expanded.
But it's hard to configure: you have to receive options (of expand) in Template#initialize, then you have to define tools inside Template.on_expand block, and if you want to access options from Template#initialize — you have to access template argument of on_expand block and pass it to tools code. Also, you have to write to_run do instead of def run for accessing local variable. And there is many problems and template variable passing through methods if you split code to modules, files, like separate tools or a module for common code between tools.
#46 can help a bit, but there is another idea and a way to simplify a code:
Instead of receiving template argument inside on_expand block make it available through getter inside tools.
Some work-around via instance variable you can see here: https://github.com/AlexWayfer/gem_toys/blob/715dd1e/lib/gem_toys/template.rb
Do I explain the subject clearly? What do you think about this?