rogerdpack-arguments 0.4.3.2 → 0.4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/arguments/class.rb +13 -1
- data/spec/arguments_spec.rb +4 -0
- metadata +1 -1
data/lib/arguments/class.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# used to throw if you try to call it on a binary method
|
2
2
|
class BinaryMethodError < Exception; end
|
3
3
|
|
4
|
-
|
4
|
+
module NamedArgs
|
5
5
|
|
6
6
|
def named_arguments_for *methods
|
7
7
|
methods.each do |method|
|
@@ -48,3 +48,15 @@ class Class
|
|
48
48
|
alias :named_args_for :named_arguments_for
|
49
49
|
|
50
50
|
end
|
51
|
+
|
52
|
+
# for some reason in 1.9 module doesn't take methods from class...at least not like 1.8 did
|
53
|
+
# so we have to mix them into both
|
54
|
+
class Class
|
55
|
+
include NamedArgs
|
56
|
+
end
|
57
|
+
|
58
|
+
class Module
|
59
|
+
include NamedArgs
|
60
|
+
end
|
61
|
+
|
62
|
+
|
data/spec/arguments_spec.rb
CHANGED
@@ -75,6 +75,10 @@ describe Arguments do
|
|
75
75
|
}
|
76
76
|
end
|
77
77
|
|
78
|
+
it "should work with modules too" do
|
79
|
+
lambda { module TestMod; def go(a); end; named_arguments_for :go; end }
|
80
|
+
end
|
81
|
+
|
78
82
|
it "should raise if you try to call it on a c (binary) method" do
|
79
83
|
lambda { class String; named_arguments_for(:strip); end }.should raise_error( BinaryMethodError )
|
80
84
|
end
|