lib/universa/lazy.rb in universa-3.12.0.2 vs lib/universa/lazy.rb in universa-3.12.4.1
- old
+ new
@@ -52,10 +52,17 @@
# prevent from creation multiple instances of LazyValue's
@@lazy_creation_mutex = Mutex.new
def Lazy.included(other)
- # implement class-level lazy instance var definition
+
+
+ # @!method lazy(name, &block)
+ # Provides create lazy instance variable calculated by a provided block
+ # @param [String] name of the created field
+ # @return [string] Returns the greeting.
+ # @yield calculates the value for the variable
+
def other.lazy(name, &block)
define_method(name.to_sym) {
x = @@lazy_creation_mutex.synchronize {
cache_name = :"@__#{name}__cache"
if !(x = instance_variable_get(cache_name))
\ No newline at end of file