Sha256: 37327a26d1182c04deac95033420d0b1aba79f383f51f97c38dea371cdcf8397

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

require 'ruby_ext/core'

require 'set'

module RubyExt
  %w(Callbacks DeclarativeCache Observable OpenConstructor Tuple).each do |const|
    autoload const, "ruby_ext/more/#{const.underscore}"
  end
end

# Declarative cache.
Module.class_eval do
  def cache_method *methods
    ::RubyExt::DeclarativeCache.cache_method self, *methods
  end

  def cache_method_with_params *methods
    ::RubyExt::DeclarativeCache.cache_method_with_params self, *methods
  end

  def clear_cache obj
    obj.instance_variables.each do |iv|
      obj.send :remove_instance_variable, iv if iv =~ /_cache$/ or iv =~ /_cache_check$/
    end
  end
end

# Printing with multiple arguments.
Kernel.class_eval do
  alias_method :old_p, :p
  def p *args
    puts args.collect{|a| a.inspect}.join(' ')
    return *args
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_ext-0.5.10 lib/ruby_ext/more.rb