multi_type 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/multi_type/group.rb +8 -5
- data/lib/multi_type/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b589809c866c9ece5f57b9b3d72799aab22129b8
|
4
|
+
data.tar.gz: 9d2993423e9ad8685e2a99f42a5111c7c83e3cbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 940694cda9b2407c90ca12ae326d4198e4346fbfa29c3d19613890d6bf8019e2273809d2f9bcfbabb74ff066fff98e3b0214fc1ee0fe3c0cc4a341d5b49f41d3
|
7
|
+
data.tar.gz: 132ad1af7e1cb967421cafcbddc9aa783e1028d46914528561b8c9997b6e95419ea438574f4b0c6f7ca707ddd3a4c0e9c69b3522b8d8800e3897baa5a015d20d
|
data/README.md
CHANGED
data/lib/multi_type/group.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
module MultiType
|
2
2
|
class Group
|
3
|
+
attr_reader :klasses
|
4
|
+
alias_method :to_a, :klasses
|
5
|
+
|
3
6
|
def initialize(klasses)
|
4
|
-
@klasses = klasses
|
7
|
+
@klasses = klasses.uniq
|
5
8
|
end
|
6
9
|
|
7
10
|
def ===(other)
|
8
|
-
|
11
|
+
klasses.any? { |k| k === other }
|
9
12
|
end
|
10
13
|
|
11
14
|
def inspect
|
12
|
-
?< +
|
15
|
+
?< + klasses.map(&:inspect) * ", " + ?>
|
13
16
|
end
|
14
17
|
|
15
18
|
def to_module
|
@@ -18,14 +21,14 @@ module MultiType
|
|
18
21
|
Module.new do
|
19
22
|
extend self
|
20
23
|
|
21
|
-
%i[inspect ===].each do |m|
|
24
|
+
%i[inspect to_a ===].each do |m|
|
22
25
|
define_method m do |*args|
|
23
26
|
group.public_send m, *args
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
30
|
def add(*other)
|
28
|
-
MultiType[self, *other]
|
31
|
+
MultiType[*self, *other]
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
data/lib/multi_type/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pravosud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|