object.freeze! freezes all sub-objects in an Array or Hash
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
Gemfile
LICENSE.txt
README.markdown
Rakefile
mr_freeze.gemspec

README.markdown

mr_freeze

Build Status

Real name: Dr Victor Fries

Description

Freeze arrays, hashes, and their contents

Example

gem install mr_freeze

# without mr_freeze
hash = {"some" => "hash"}.freeze
hash["some"].sub!(/h/, "b")

# => uh oh... we've changed the string in place

# load mr_freeze
require 'rubygems'
require 'mr_freeze'

# with mr_freeze
hash = {"victor" => "fries"}.freeze!
hash["victor"].sub!(/f/, "c")

# => TypeError: can't modify frozen string

License

mr_freeze is released under the MIT License.