Sha256: ee0cb45a0cb0aa29ab15286242895a41206efdf099d944a40f0e61a8c3097966

Contents?: true

Size: 909 Bytes

Versions: 4

Compression:

Stored size: 909 Bytes

Contents

require 'ruby_ext/core'

require 'ruby_ext/more/must'

require 'set'

# Lazy loading.
autoload :UserError, 'ruby_ext/more/user_error'
module RubyExt
  %w(Callbacks CallbacksProxy 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

4 entries across 4 versions & 1 rubygems

Version Path
ruby_ext-4.0.3 lib/ruby_ext/more.rb
ruby_ext-4.0.2 lib/ruby_ext/more.rb
ruby_ext-4.0.1 lib/ruby_ext/more.rb
ruby_ext-4.0.0 lib/ruby_ext/more.rb