methodfinder 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.markdown +14 -5
  2. data/lib/methodfinder.rb +3 -3
  3. metadata +2 -2
data/README.markdown CHANGED
@@ -1,9 +1,18 @@
1
1
  Description
2
2
  ---
3
3
 
4
- A Smalltalk-like Method Finder for Ruby. Provided with a receiver, a
5
- desired result and possibly some arguments, it will list all methods
6
- that produce the result when called on the receiver with the arguments.
4
+ This project was inspired by Smalltalk's Method Finder.
5
+
6
+ Provided with a receiver, a desired result and possibly some
7
+ arguments, `MethodFinder.find` will list all methods that produce the
8
+ given result when called on the receiver with the provided arguments.
9
+
10
+ This gem also adds `Object#find_method`, which besides offering an
11
+ alternate interface to pretty much the same functionality, also allows
12
+ you to test for state other than the return value of the method.
13
+
14
+ All of this probably sounds more complicated than it really is, just
15
+ look at the examples below.
7
16
 
8
17
  Usage
9
18
  ---
@@ -27,8 +36,8 @@ by Ryan Bates, this gem now also provides an alternative interface:
27
36
  => [:%, :<=>, :>>, :[], :gcd, :modulo, :remainder]
28
37
 
29
38
  Inside `find_method`'s block, the receiver is available as block
30
- argument the special method `unknown` is used as a placeholder for the
31
- desired method.
39
+ argument and the special method `unknown` is used as a placeholder for
40
+ the desired method.
32
41
 
33
42
  Warning
34
43
  ---
data/lib/methodfinder.rb CHANGED
@@ -2,11 +2,11 @@ require 'stringio'
2
2
 
3
3
  class Object
4
4
  def find_method(*args, &block)
5
- self.methods.sort.map(&:intern).map do |met|
5
+ self.methods.sort.map(&:intern).select do |met|
6
6
  self.class.class_eval %{ alias :unknown #{met} }
7
7
  obj = self.dup rescue self
8
- [met, (yield obj rescue nil)]
9
- end.select(&:last).map(&:first)
8
+ yield obj rescue nil
9
+ end
10
10
  end
11
11
  end
12
12
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: methodfinder
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.0
5
+ version: 1.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Kohl
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-31 00:00:00 +02:00
13
+ date: 2011-04-05 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies: []
16
16