我有一个像臭的方法:
def search_record(*args)
record = expensive_operation_1(foo)
return record unless record.nil?
record = expensive_operation_2(foo, bar)
return record unless record.nil?
record = expensive_operation_3(baz)
return record unless record.nil?
record = expensive_operation_4(foo, baz)
return record unless record.nil?
end
Run Code Online (Sandbox Code Playgroud)
对于"除非无效"的"回复结果",是否有一个好的红宝石成语?
或者我应该写一个return_unless_nil(&blk)
方法?
(注意每个调用的args不同,所以我不能简单地迭代它们)
我有一个带有私有git repo的Gemfile,格式如下:
gem 'magic_beans', :git => "git@git.example.com:magic_beans.git', :branch => 'super_beans'
当我bundle install
,Gemfile.lock将其锁定到特定的SHA修订版.
我可以让bundler始终检查并使用最新的SHA提交和/或更新Gemfile.lock吗?请注意,当我将更新推送到super_beans
分支时,我不会修改gem版本.
理想情况下,每次运行bundle
它都会检查上游git repo以获得更新的分支SHA修订版.