casting 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/casting/method_consolidator.rb +19 -0
- data/lib/casting/version.rb +1 -1
- data/test/method_consolidator_test.rb +81 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41fa81d5c1ff0bf53479e39ac9f655156e405bb8
|
4
|
+
data.tar.gz: 82daadbcd47eff9a0a3cf570a362b621e4e7227d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61173fac0029519e94f9554eb0c167682da7becc73aea8e53ca83323871d8640ad13e43c2dab48961183886f4cf58151c566c7efacc870a3c9dd8c18f4582ac8
|
7
|
+
data.tar.gz: be0f1e72cf3267102c238cd11291169531b76ff867e42a4396ae98659507a5b10483b1236ac5006e61acc40abfa4ad1c7ec27603264758e4d1fb007fad934cf1
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Casting
|
2
|
+
module MethodConsolidator
|
3
|
+
def methods(all=true)
|
4
|
+
(super + delegated_methods(all)).uniq
|
5
|
+
end
|
6
|
+
|
7
|
+
def public_methods(include_super=true)
|
8
|
+
(super + delegated_public_methods(include_super)).uniq
|
9
|
+
end
|
10
|
+
|
11
|
+
def protected_methods(include_super=true)
|
12
|
+
(super + delegated_protected_methods(include_super)).uniq
|
13
|
+
end
|
14
|
+
|
15
|
+
def private_methods(include_super=true)
|
16
|
+
(super + delegated_private_methods(include_super)).uniq
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/casting/version.rb
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Casting::MethodConsolidator, '#methods' do
|
4
|
+
let(:client){
|
5
|
+
object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
|
6
|
+
object.cast_as(TestPerson::Greeter)
|
7
|
+
object
|
8
|
+
}
|
9
|
+
|
10
|
+
it "returns all instance methods including private from the object and it's delegates" do
|
11
|
+
assert_includes(client.methods(true), :psst)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns all public instance methods from the object and it's delegates" do
|
15
|
+
refute_includes(client.methods(false), :psst)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns all protected instance methods from the object and it's delegates" do
|
19
|
+
assert_includes(client.methods(true), :hey)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe Casting::MethodConsolidator, '#public_methods' do
|
24
|
+
let(:client){
|
25
|
+
object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
|
26
|
+
object.cast_as(TestPerson::Greeter)
|
27
|
+
object
|
28
|
+
}
|
29
|
+
|
30
|
+
it "returns all public_methods and those from it's delegates" do
|
31
|
+
assert_includes(client.public_methods, :greet)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "excludes all protected_methods and those from it's delegates" do
|
35
|
+
refute_includes(client.public_methods, :hey)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "excludes all private_methods from the object and it's delegates" do
|
39
|
+
refute_includes(client.public_methods, :psst)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe Casting::MethodConsolidator, '#protected_methods' do
|
44
|
+
let(:client){
|
45
|
+
object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
|
46
|
+
object.cast_as(TestPerson::Greeter)
|
47
|
+
object
|
48
|
+
}
|
49
|
+
|
50
|
+
it "excludes all public_methods and those from it's delegates" do
|
51
|
+
refute_includes(client.protected_methods, :greet)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns all protected_methods and those from it's delegates" do
|
55
|
+
assert_includes(client.protected_methods, :hey)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "excludes all private_methods from the object and it's delegates" do
|
59
|
+
refute_includes(client.protected_methods, :psst)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe Casting::MethodConsolidator, '#private_methods' do
|
64
|
+
let(:client){
|
65
|
+
object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
|
66
|
+
object.cast_as(TestPerson::Greeter)
|
67
|
+
object
|
68
|
+
}
|
69
|
+
|
70
|
+
it "excludes all public_methods and those from it's delegates" do
|
71
|
+
refute_includes(client.private_methods, :greet)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "excludes all protected_methods and those from it's delegates" do
|
75
|
+
refute_includes(client.private_methods, :hey)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "excludes all private_methods from the object and it's delegates" do
|
79
|
+
assert_includes(client.private_methods, :psst)
|
80
|
+
end
|
81
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Gay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcard
|
@@ -35,12 +35,13 @@ extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
37
|
- lib/casting.rb
|
38
|
-
- lib/casting/
|
38
|
+
- lib/casting/client.rb
|
39
39
|
- lib/casting/delegation.rb
|
40
|
+
- lib/casting/method_consolidator.rb
|
40
41
|
- lib/casting/missing_method_client.rb
|
41
42
|
- lib/casting/missing_method_client_class.rb
|
42
43
|
- lib/casting/prepared_delegation.rb
|
43
|
-
- lib/casting/
|
44
|
+
- lib/casting/version.rb
|
44
45
|
- test/test_helper.rb
|
45
46
|
- test/casting_19_test.rb
|
46
47
|
- test/casting_20_test.rb
|
@@ -48,6 +49,7 @@ files:
|
|
48
49
|
- test/class_refinement_test.rb
|
49
50
|
- test/client_test.rb
|
50
51
|
- test/delegation_test.rb
|
52
|
+
- test/method_consolidator_test.rb
|
51
53
|
- test/missing_method_client_test.rb
|
52
54
|
homepage: http://github.com/saturnflyer/casting
|
53
55
|
licenses:
|
@@ -81,5 +83,6 @@ test_files:
|
|
81
83
|
- test/class_refinement_test.rb
|
82
84
|
- test/client_test.rb
|
83
85
|
- test/delegation_test.rb
|
86
|
+
- test/method_consolidator_test.rb
|
84
87
|
- test/missing_method_client_test.rb
|
85
88
|
has_rdoc:
|