def_enum_helper 0.4.0 → 0.5.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: edd5b5abefcbb09535b94af42a8b7019c127c2f2
4
- data.tar.gz: 01b90f02d87a761fa00ae5f674c3f6e3967b49e2
3
+ metadata.gz: 95c77f50f6fc43c3dd328a63a4bc291333a418e9
4
+ data.tar.gz: 838fd30ffac58e56b35a89bde9feb04fe671ed06
5
5
  SHA512:
6
- metadata.gz: 6e5068f60b09966bba27aa60c6d362368fa26065a8601676a66d021be4a6d16db8aee817166bb4851dcb0d93e7a82117c46def552f6e2c05a87d9342de6147b8
7
- data.tar.gz: 61904a4a0b3d0bf9017509cfe1ec10f075df6f3590b0dbd69e8a7fff9e4311d0b7ab9009cbad03f2d3ba6338f29000106f335c93232d5959886b211da3550a1b
6
+ metadata.gz: 5fc0cb77e66bd8e69026b65c28c87b2591d32940fd4342429ece0c876d8c8081e89df5ec8e2c2f142dc2a45682f284b0c5507bb8ffcf69123050c46cf98da894
7
+ data.tar.gz: 32d19d4b7e6d5e82c05e5570c6ecdcf51095ed024bd97b68e52a0b84bf85a430b16c38d8461b6616c60d260829dbac13f3fe45886597943d376b6de32abc5a8e
@@ -1,3 +1,3 @@
1
1
  module DefEnumHelper
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -88,7 +88,12 @@ def define_subscript_method(m, enum_index_hash, enum_display_hash)
88
88
  when String
89
89
  enum_display_hash[k]
90
90
  when Symbol
91
- enum_index_hash[const_get(k)]
91
+ index = if self.is_a?(Module)
92
+ const_get(k)
93
+ else
94
+ Kernel.const_get(k)
95
+ end
96
+ enum_index_hash[index]
92
97
  else
93
98
  enum_index_hash[k]
94
99
  end
@@ -130,5 +135,9 @@ def def_enum_struct_with_index(module_name, enum_hash, index_name: :index, displ
130
135
 
131
136
  define_enum_methods(m, enum_index_hash, enum_display_hash)
132
137
 
133
- const_set(module_name, m)
138
+ if self.is_a?(Module)
139
+ const_set(module_name, m)
140
+ else
141
+ Kernel.const_set(module_name, m)
142
+ end
134
143
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: def_enum_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Zhang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-16 00:00:00.000000000 Z
11
+ date: 2016-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler