
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
= dirty-memoize
== DESCRIPTION
Like Memoize, but designed for mutable and parametizable objects
Use when:
== SYNOPSIS
By default, the method to compute should be called #compute. Set constant DIRTY_COMPUTE to the name of other method if you need it
Example:
require 'dirty-memoize'
class Factorial
include DirtyMemoize
attr_reader :result
attr_writer :n
dirty_memoize :result
dirty_writer :n
def initialize
@n=nil
@result=nil
end
def fact(n)
return 1 if n==1
n*(fact(n-1))
end
def compute
puts "Computing the factorial!"
@result=fact(@n)
end
end
a=Factorial.new
a.n=10
puts "Our object is dirty: #{a.dirty?}"
puts "The result is: #{a.result}"
puts "Our object is no longer dirty: #{a.dirty?}"
puts "And the result is cached without calling the compute method: #{a.result}"
puts "Now, n is changed to 5"
a.n=5
# Object is now dirty. So, compute will be called when we get result
puts "The result is: #{a.result}"
== Sugestions
== Copyright
Copyright (c) 2010-2011 Claudio Bustos. See LICENSE for details.
FAQs
Unknown package
We found that dirty-memoize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.