我正在使用 Ruby on Rails 3.2.9 和 Ruby 1.9.3。我有以下case
陈述:
case
when private?
case
when not_active? then [:a, :b, :c, :d]
when active? then raise "private cannot be active"
else raise "not recognized"
end
when shared?
case
when not_active? then [:a, :b, :c]
when active? then raise "shared cannot be active"
else raise "not recognized"
end
when public?
case
when not_active? then [:a, :b]
when active? then [:a]
else raise "not recognized"
end
else raise "not recognized"
end
如何重构上面的代码?