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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 629a1484c92cc74994972dadea22b83bbde645a5
4
- data.tar.gz: 3c536ff19cda406925ac83a5e6fb512da09a4609
3
+ metadata.gz: b589809c866c9ece5f57b9b3d72799aab22129b8
4
+ data.tar.gz: 9d2993423e9ad8685e2a99f42a5111c7c83e3cbb
5
5
  SHA512:
6
- metadata.gz: 522e8bbd21769ee613fc1b5d7b75b38d7f2f40fd08822736593270e53f60d4b03af10af3bc3c9a4249aa71a5a91229b85b5517c6909b2a3b99ecf61a2ed2ba3b
7
- data.tar.gz: 3fb2f2afbfb0598c7926223e236214aa944370021bb9038e7b9f4d7bf679165ded422ea6c0a9a3ad43ae86125025229ace0f1c67e7e834af590f9a37391247d2
6
+ metadata.gz: 940694cda9b2407c90ca12ae326d4198e4346fbfa29c3d19613890d6bf8019e2273809d2f9bcfbabb74ff066fff98e3b0214fc1ee0fe3c0cc4a341d5b49f41d3
7
+ data.tar.gz: 132ad1af7e1cb967421cafcbddc9aa783e1028d46914528561b8c9997b6e95419ea438574f4b0c6f7ca707ddd3a4c0e9c69b3522b8d8800e3897baa5a015d20d
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Code Climate](https://codeclimate.com/github/rwz/multi_type/badges/gpa.svg)](https://codeclimate.com/github/rwz/multi_type)
2
+
1
3
  # MultiType
2
4
 
3
5
  MultiType lets you create weird module-like objects that match object
@@ -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
- @klasses.any? { |k| k === other }
11
+ klasses.any? { |k| k === other }
9
12
  end
10
13
 
11
14
  def inspect
12
- ?< + @klasses.map(&:inspect).join(", ") + ?>
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
@@ -1,3 +1,3 @@
1
1
  module MultiType
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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-26 00:00:00.000000000 Z
11
+ date: 2015-10-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: