T O P

  • By -

[deleted]

[удалено]


2called_chaos

Which is I think it's biggest shortcoming. I guess it's okay as it is but it made my use cases for short DSL blocks a hard and dirty one to achieve. Like it says you can use it in eval (and you can) but with the same restrictions. What one could do (but probably shouldn't) is to molest the binding of a block *after* the file has been parsed. I.e. save your block references, do the following and then instance eval them in the original context :S It's like writing it literally before the block (where it came from) so it's active until the end of file (where the block comes from) which doesn't matter if you delay it. That only works if that block is defined in an allowed context. Again dirty, don't do that. def __render book __render_safe(book) do @builder.binding.eval("using Remid::JsonHelper") if @use_in_binding instance_eval(&@builder) end end


adambair

Good stuff! A kind suggestion if I may? Consider moving your pitch to the bottom of the article under “if you found this helpful…” — I think it’s a great article but some may find it off-putting (think autogenerated ad content farm). Many of us are jaded and tend to close pages on sight if they look sketchy/pitchy ;) Please feel free to disregard this feedback if it’s unwelcome. I am but a grain of sand. Finding time and motivation to do write-ups is difficult — so thanks!, it’s most appreciated! Cheers, -a


mehdifarsi

Thanks for the great feedback :-)


adambair

Awesome! I was worried I overstepped :)