Sha256: aa0b61918f30ca7e64d4a8e58a40d44023a99764c7f0cfaec94d6eea6103351d
Contents?: true
Size: 680 Bytes
Versions: 1
Compression:
Stored size: 680 Bytes
Contents
module Prezzo module TransientDSL def self.included(base) base.class_eval do base.extend(ClassMethods) end end module ClassMethods def transient(name) transients << name define_method(name) do cached_transients[name] ||= yield end end def transients @transients ||= [] end end def compile_transients self.class.transients.reduce({}) do |acc, name| public_send(name) # force transient cache acc[name] = cached_transients[name] acc end end private def cached_transients @cached_transients ||= {} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prezzo-1.0.0.pre.rc | lib/prezzo/transient_dsl.rb |