map_by_method 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/map_by_method.rb +12 -5
- data/lib/map_by_method/version.rb +1 -1
- data/website/index.html +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.8.1 2007-09-06
|
2
|
+
|
3
|
+
* Ok ok ok, now it works in all places I've had it fail before
|
4
|
+
* respond_to? now has an optional 2nd parameter as required by ActiveRecord's AssociationProxy
|
5
|
+
* MAP_BY_METHOD_FORMAT only created if doesn't exist
|
6
|
+
|
1
7
|
== 0.8.0 2007-09-05
|
2
8
|
|
3
9
|
* Works in Rails - respond_to? must return true or false, or rather, cannot return MatchData [thx Mislav Marohnić]
|
data/lib/map_by_method.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
module MapByMethod
|
2
|
-
MAP_BY_METHOD_FORMAT = /^(map|collect|select|each|reject|sort_by|group_by|index_by)(?:_by)?_(\w+[?!]?)$/
|
2
|
+
MAP_BY_METHOD_FORMAT = /^(map|collect|select|each|reject|sort_by|group_by|index_by)(?:_by)?_(\w+[?!]?)$/ unless defined?(MAP_BY_METHOD_FORMAT)
|
3
3
|
|
4
4
|
module InstanceMethods
|
5
5
|
alias_method :respond_to_before_map_by_method?, :respond_to?
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
# Support for include_priv due to ActiveRecord's AssociationProxy expecting it;
|
8
|
+
# Support degrades to normal single argument respond_to?
|
9
|
+
def respond_to?(method, include_priv = false)
|
10
|
+
if include_priv
|
11
|
+
respond_to_before_map_by_method?(method, include_priv) or
|
12
|
+
!!method.to_s.match(MAP_BY_METHOD_FORMAT)
|
13
|
+
else
|
14
|
+
respond_to_before_map_by_method?(method) or
|
15
|
+
!!method.to_s.match(MAP_BY_METHOD_FORMAT)
|
16
|
+
end
|
10
17
|
end
|
11
18
|
|
12
19
|
protected
|
@@ -35,4 +42,4 @@ module MapByMethod
|
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
38
|
-
Array.send :include, MapByMethod
|
45
|
+
Array.send :include, MapByMethod unless Array.ancestors.include?(MapByMethod)
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1 class=primary>Map By Method</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/drnicutilities"; return false'>
|
35
35
|
Get Version
|
36
|
-
<a href="http://rubyforge.org/projects/drnicutilities" class="numbers">0.8.
|
36
|
+
<a href="http://rubyforge.org/projects/drnicutilities" class="numbers">0.8.1</a>
|
37
37
|
</div>
|
38
38
|
<h1><code>["1","2","3"]. map_by_to_i => [1,2,3]</code></h1>
|
39
39
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4.3
|
|
3
3
|
specification_version: 1
|
4
4
|
name: map_by_method
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
7
|
-
date: 2007-09-
|
6
|
+
version: 0.8.1
|
7
|
+
date: 2007-09-06 00:00:00 +02:00
|
8
8
|
summary: Replacement for map {|obj| obj.action} and Symbol.to_proc which is much cleaner and prettier NOW WORKS with ActiveRecord Associations!!
|
9
9
|
require_paths:
|
10
10
|
- lib
|