adamantium
Create immutable objects with ease.
This is a small standalone gem featuring a module ripped out from axiom.
It allows you to make objects immutable in a simple, unobtrusive way.
Examples
require 'adamantium'
require 'securerandom'
class Example
include Adamantium
def initialize
@attribute = "foo bar"
end
attr_reader :attribute
def random
[SecureRandom.hex(6)]
end
memoize :random
def buffer
StringIO.new
end
memoize :buffer, freezer: :noop
def random2
[SecureRandom.hex(6)]
end
memoize :random2, freezer: :flat
end
class FlatExample
include Adamantium::Flat
def initialize
@attribute = "foo bar"
end
attr_reader :attribute
def random
[SecureRandom.hex(6)]
end
memoize :random
end
Credits
Contributing
See CONTRIBUTING.md for details.
Copyright
Copyright © 2012-2013 Dan Kubb. See LICENSE for details.