Skip to content

Instantly share code, notes, and snippets.

@scruti
Last active December 25, 2015 04:19
Show Gist options
  • Save scruti/6916428 to your computer and use it in GitHub Desktop.
Save scruti/6916428 to your computer and use it in GitHub Desktop.
Wrapping RoR scopes with lambdas and updating lambdas to new syntax. Done with Sublime Text find & replace.

Moving from lambda { |param| ... } to ->(param) { ... }

  • Find What: lambda\s*\{\s*\|(\w+,*\s*\w+)\|
  • Replace With: ->($1) {

Wrapping scopes with lambdas

  • Find What: scope\s:(\w+),\s(\w+.+)
  • Replace With: scope :$1, -> { $2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment