Permalink
Browse files

Allow customization of the ObjectMixin methods.

Either use Looksee.rename(old_name => new_name, ...) or set the
LOOKSEE_METHODS environment variable.
  • Loading branch information...
1 parent 57e0518 commit 01dc891dea440c22264c6c1a3fabfe0869d38442 @oggy committed Mar 15, 2011
Showing with 22 additions and 0 deletions.
  1. +20 −0 lib/looksee/core_ext.rb
  2. +2 −0 spec/spec_helper.rb
View
@@ -53,6 +53,26 @@ def ls(*args)
def edit(name)
Editor.new(Looksee.editor).edit(self, name)
end
+
+ def self.rename(renamings) # :nodoc:
+ renamings.each do |old_name, new_name|
+ alias_method new_name, old_name
+ remove_method old_name
+ end
+ end
+ end
+
+ #
+ # Rename the methods added to every object. Example:
+ #
+ # rename :ls => :_ls, :edit => :_edit
+ #
+ def self.rename(renamings)
+ ObjectMixin.rename(renamings)
+ end
+
+ (ENV['LOOKSEE_METHODS'] || '').scan(/([\w_]+)=([\w_]+)/) do
+ rename $1.to_sym => $2.to_sym
end
Object.send :include, ObjectMixin
View
@@ -1,3 +1,5 @@
+ENV['LOOKSEE_METHODS'] = nil
+
require 'rspec'
require 'mocha'
require 'looksee'

0 comments on commit 01dc891

Please sign in to comment.