Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Advanced Ruby for Rails Devs, by Sherif Abushadi

Paul Burt
October 23, 2015

Advanced Ruby for Rails Devs, by Sherif Abushadi

From the October 23rd (2015) SFRails meetup:

Paul Burt

October 23, 2015

More Decks by Paul Burt

Other Decks in Programming


  1. What are we talking about? Ruby claims to make things

    easier for developers, but sometimes that flexibility feels like complexity. For example, Ruby supports 4 different ways to reference (and later execute) a piece of code: - methods - blocks - procs - lambdas
  2. We’re talking about: procs and lambdas what if ... you

    could treat code as if it were data or an object? that’s what procs and lambdas do for you. they let you wrap code and pass it around in variables and collections. and the two are essentially the same thing except for a little syntax and 2 differences in behavior.
  3. We’re talking about: procs and lambdas both of them are

    closures (they keep a reference to the current context) and respond to the call() method
  4. We’re talking about: procs Procs: - don’t enforce arity -

    return to the scope in which they were defined
  5. We’re talking about: open source for study Sample Project: GitLab

    - github.com/gitlabhq/gitlabhq - Self hosted Git management software Fast and easy Git repositories, hosted either on your own or at Gitlab.com. Create projects and repositories, manage access and perform collaborative code reviews. - 200,000 lines of code and 600 classes among 2800 files
  6. summary - Ruby let’s you “name” a piece of code

    to run later. - methods and blocks can’t be passed around like objects - procs and lambdas can. what else? - embrace the confusion - have faith in your own work - keep exploring, playfully