Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
require 'rubygems' require 'recursively' require 'facet/hash/stringify_keys' require 'facet/hash/symbolize_keys' require 'facet/symbol/to_proc' # Array Example nested = [ 'a', 'b', [ 'c', 'd', [ 'e', 'f' ] ], 'g', [ 'h' ] ] nested.recursively!(&:upcase) # => ["A", "B", ["C", "D", ["E", "F"]], "G", ["H"]] # Hash example options = { :find => { :conditions => { 'first_name' => 'john', :hair_color => 'brown' }, 'order' => 'last_name', :limit => 10 }, 'create' => { :conditions => [ "hair_color = ?", 'brown' ] } } options.recursively!(&:symbolize_keys) options[:find][:conditions][:first_name] # => "john" options.recursively!(&:stringify_keys) options['find']['conditions']['hair_color'] # => "brown"
This paste will be private.
From the Design Piracy series on my blog: