
Security News
Researcher Exposes Zero-Day Clickjacking Vulnerabilities in Major Password Managers
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
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.
require 'adamantium'
require 'securerandom'
class Example
# Inclusion of Adamantium defaults to deep freeze behavior
# of constructor and memoizer
include Adamantium
# Instance and attributes (ivars) are frozen per default
# Example:
#
# object = Example.new
# object.frozen? # => true
# object.attribute.frozen? # => true
#
def initialize
@attribute = "foo bar"
end
attr_reader :attribute
# Memoized method with deeply frozen value (default)
# Example:
#
# object = Example.new
# object.random => ["abcdef"]
# object.random => ["abcdef"]
# object.random.frozen? => true
# object.random[0].frozen? => true
#
def random
[SecureRandom.hex(6)]
end
memoize :random
# Memoized method with non frozen value
# Example:
#
# object = Example.new
# object.buffer # => <StringIO:abcdef>
# object.buffer # => <StringIO:abcdef>
# object.buffer.frozen? # => false
#
def buffer
StringIO.new
end
memoize :buffer, freezer: :noop
# Memoized method with shallow frozen value
# Example:
#
# object = Example.new
# object.random2 => ["abcdef"]
# object.random2 => ["abcdef"]
# object.random2.frozen? => true
# object.random2[0].frozen? => false
#
def random2
[SecureRandom.hex(6)]
end
memoize :random2, freezer: :flat
end
class FlatExample
# Inclusion of Adamantium::Flat defaults to shallow frozen
# behavior for memoizer and constructor
include Adamantium::Flat
# Instance is frozen but attribute is not
# object = FlatExample.new
# object.frozen? # => true
# object.attribute.frozen? # => false
def initialize
@attribute = "foo bar"
end
attr_reader :attribute
# Memoized method with flat frozen value (default with Adamantium::Flat)
# Example:
#
# object = Example.new
# object.random => ["abcdef"]
# object.random => ["abcdef"]
# object.random.frozen? => true
# object.random[0].frozen? => false
#
def random
[SecureRandom.hex(6)]
end
memoize :random
end
See CONTRIBUTING.md for details.
Copyright © 2012-2013 Dan Kubb. See LICENSE for details.
FAQs
Unknown package
We found that adamantium demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers

Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.

Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.