ruby-enum 0.7.0 → 0.7.1

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: 971c1b5b0f1efc517293ebe5adfaed75bd2ef8cd
4
- data.tar.gz: a7d4f6c03985bcd6ddee0e09938b4cd8dc860d1e
3
+ metadata.gz: ff88e3a9dd8dc2188f929ad3e84cc86a0fd313c3
4
+ data.tar.gz: 66f8dd956d3eeb27fd2457c56f76a144c30a1518
5
5
  SHA512:
6
- metadata.gz: 20ac5e36b84f00a29ae233b6e100747ae18e06264037ef98223d4026b900614f5522e7afc97dce9b8e4c9b2828b2c4de610ece759fb688d452df32b07b113d4c
7
- data.tar.gz: e00bdf6c6296e281285da12c1bd92eb5a293adae78fe3e8faf24db098b237db9ab353fe6076f1cee4302107f5d0e1a6f72d14486825cdf279c762a1a3f5bda93
6
+ metadata.gz: 8b4196088d70c8cfabf6e2adfe15a99744343dabc8b4275b26340314186a755375efac54900d1b4e61957ed13d7e818fcac860fd7dac6a04350efdbbf479f79d
7
+ data.tar.gz: 409a290aa4ed199c6ec84fba971b33b4e176625c400ba313de111d7dacb3180f32a5ba83ace957f7e01875483b00de50ea7c9f884483f6df0b1d4d6c295c9685
@@ -1,3 +1,7 @@
1
+ ### 0.7.1 (23/2/2017)
2
+
3
+ * [#16](https://github.com/dblock/ruby-enum/pull/16): Replaces const_missing method in favor of const_set - [@laertispappas](https://github.com/laertispappas).
4
+
1
5
  ### 0.7.0 (21/2/2017)
2
6
 
3
7
  * [#3](https://github.com/dblock/ruby-enum/pull/13): Adds support for sub classing an Enum - [@laertispappas](https://github.com/laertispappas).
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-enum (0.7.0)
4
+ ruby-enum (0.7.1)
5
5
  i18n
6
6
 
7
7
  GEM
@@ -30,6 +30,8 @@ module Ruby
30
30
  new_instance = new(key, value)
31
31
  @_enum_hash[key] = new_instance
32
32
  @_enums_by_value[value] = new_instance
33
+
34
+ const_set key, value
33
35
  end
34
36
 
35
37
  def validate_key!(key)
@@ -45,14 +47,7 @@ module Ruby
45
47
  end
46
48
 
47
49
  def const_missing(key)
48
- enum_instance = @_enum_hash && @_enum_hash[key]
49
- if enum_instance
50
- @_enum_hash[key].value
51
- elsif superclass.instance_variable_get(:@_enum_hash)
52
- superclass.send(:const_missing, key)
53
- else
54
- raise Ruby::Enum::Errors::UninitializedConstantError, name: name, key: key
55
- end
50
+ raise Ruby::Enum::Errors::UninitializedConstantError, name: name, key: key
56
51
  end
57
52
 
58
53
  # Iterate over all enumerated values.
@@ -1,5 +1,5 @@
1
1
  module Ruby
2
2
  module Enum
3
- VERSION = '0.7.0'.freeze
3
+ VERSION = '0.7.1'.freeze
4
4
  end
5
5
  end
Binary file
Binary file
@@ -169,4 +169,12 @@ describe Ruby::Enum do
169
169
  expect { EmptyEnums::ORANGE }.to raise_error Ruby::Enum::Errors::UninitializedConstantError
170
170
  end
171
171
  end
172
+
173
+ context 'when a constant is redefined in a global namespace' do
174
+ before do
175
+ RED = 'black'.freeze
176
+ end
177
+
178
+ it { expect(Colors::RED).to eq 'red' }
179
+ end
172
180
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-21 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -48,6 +48,7 @@ files:
48
48
  - lib/ruby-enum/version.rb
49
49
  - lib/ruby_enum.rb
50
50
  - pkg/ruby-enum-0.7.0.gem
51
+ - pkg/ruby-enum-0.7.1.gem
51
52
  - ruby-enum.gemspec
52
53
  - spec/ruby-enum/enum_spec.rb
53
54
  - spec/ruby-enum/version_spec.rb