enumerative 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,11 +30,19 @@
30
30
 
31
31
  end
32
32
 
33
- def initialize( key_or_hash )
34
- key = key_or_hash.is_a?( Hash ) ?
35
- (key_or_hash['key'] || key_or_hash[:key]) :
36
- key_or_hash
37
- @key = key.to_s.try( :dup ).try( :freeze )
33
+ def initialize( key_hash_or_enum )
34
+ key = nil
35
+ if key_hash_or_enum.is_a?( Hash )
36
+ key = key_hash_or_enum['key'] || key_hash_or_enum[:key]
37
+ elsif key_hash_or_enum.is_a?( Enumerative::Enumeration )
38
+ key = key_hash_or_enum.key
39
+ else
40
+ key = key_hash_or_enum
41
+ end
42
+
43
+ @key = (key.nil? || key.empty?) ?
44
+ nil :
45
+ key.to_s.try( :dup ).try( :freeze )
38
46
  end
39
47
 
40
48
  def ==( other )
@@ -1,5 +1,5 @@
1
1
  module Enumerative
2
2
 
3
- VERSION = "1.4.0"
3
+ VERSION = "1.5.0"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerative
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-02-06 00:00:00.000000000 Z
13
+ date: 2014-03-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport