module_chain_method 0.1.0 → 0.1.1
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/VERSION +1 -1
- data/lib/module/chain_method.rb +3 -3
- data/test/test_module_chain_method.rb +23 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/module/chain_method.rb
CHANGED
@@ -4,11 +4,11 @@ class Module
|
|
4
4
|
def self.included target
|
5
5
|
# $stderr.puts "ChainMethod #{self.inspect}.included #{target}"
|
6
6
|
super
|
7
|
-
target.
|
8
|
-
target.extend(ModuleMethods) if Module === target
|
9
|
-
if target.method_defined?(:included)
|
7
|
+
if target.method_defined?(:included) && ! target.method_defined?(:included_without_ChainMethod)
|
10
8
|
target.send(:alias_method, :included_without_ChainMethod, :included)
|
11
9
|
end
|
10
|
+
target.extend(ClassMethods) if Class === target
|
11
|
+
target.extend(ModuleMethods) if Module === target
|
12
12
|
end
|
13
13
|
|
14
14
|
module ModuleMethods
|
@@ -28,7 +28,29 @@ class TestModuleChainMethod < Test::Unit::TestCase
|
|
28
28
|
)
|
29
29
|
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
|
+
should "handle multiple includes" do
|
33
|
+
Module::ChainMethod::Test::Foo.class_eval do
|
34
|
+
include Module::ChainMethod::Test::MyMixin
|
35
|
+
end
|
36
|
+
assert_equal(
|
37
|
+
[
|
38
|
+
"MyMixin.included Module::ChainMethod::Test::Foo",
|
39
|
+
"MyMixin.included Module::ChainMethod::Test::Foo",
|
40
|
+
],
|
41
|
+
Module::ChainMethod::Test::MyMixin.instance_variable_get("@calls")
|
42
|
+
)
|
43
|
+
|
44
|
+
f = Module::ChainMethod::Test::Foo.new
|
45
|
+
f.foo
|
46
|
+
f.bar
|
47
|
+
assert_equal(
|
48
|
+
[ "MyMixin#foo", "Foo#foo", "Foo#bar" ],
|
49
|
+
f.instance_variable_get("@calls")
|
50
|
+
)
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
32
54
|
|
33
55
|
|
34
56
|
######################################################################
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: module_chain_method
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kurt Stephens
|