Change the context/binding inside a block in ruby

前端 未结 4 1529
盖世英雄少女心
盖世英雄少女心 2020-12-13 04:27

I have a DSL in Ruby that works like so:

desc \'list all todos\'
command :list do |c|
  c.desc \'show todos in long form\'
  c.switch :l
  c.action do |globa         


        
4条回答
  •  别那么骄傲
    2020-12-13 05:17

    I wrote a class that handles this exact issue, and deals with things like @instance_variable access, nesting, and so forth. Here's the write-up from another question:

    Block call in Ruby on Rails

提交回复
热议问题