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

BostonRB Intro - November 2012

BostonRB Intro - November 2012

In which I go over some awesome new things about Ruby 2.0 and threaten the crowd with a crazy cat man.

Patrick Robertson

November 13, 2012
Tweet

More Decks by Patrick Robertson

Other Decks in Programming

Transcript

  1. Also Thanks! Will Mernagh, Eric Kidd, Dan McClain, William Josephson,

    Brian Cardarella, Wyatt Greene, Mark Bates, Scott Schulthess, Matte Noble, Kareem Kouddous, Barun Singh, and Ben Orenstein.
  2. Schedule! Rapid App Prototyping - Pascal Rettig 5-10 minute break

    - Everyone Announcements - Every Company Hiring ElasticSearch - Maurício Linhares Drinks - Trade
  3. module ActiveSupport refine String do def camelize(first_letter = :upper) case

    first_letter when :upper then ActiveSupport::Inflector.camelize(self, true) when :lower then ActiveSupport::Inflector.camelize(self, false) end end end end module ActionDispatch module Routing class RouteSet using ActiveSupport def controller_reference(controller_param) unless controller = @controllers[controller_param] controller_name = "#{controller_param.camelize}Controller" controller = @controllers[controller_param] = ActiveSupport::Dependencies.ref(controller_name) end controller.get end end end end http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-practice/
  4. def foo(str: "foo", num: 424242) [str, num] end foo(str: 'buz',

    num: 9) #=> ['buz', 9] foo(str: 'bar') # => ['bar', 424242] foo # => ['foo', 424242] foo(bar: 'buz') # => ArgumentError http://brainspec.com/blog/2012/10/08/keyword-arguments-ruby-2-0/
  5. module FooBar def hello puts 2 super end end class

    Foo def hello puts 'hello' end end class Bar < Foo prepend FooBar def hello puts 1 super end end Bar.new.hello 2 1 "hello" http://dev.af83.com/2012/10/19/ruby-2-0-module-prepend.html