active_enum 1.0.0.rc4 → 1.0.0.rc5

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
  SHA256:
3
- metadata.gz: 86faf9c711cf0ac0e6cce2450bee21b48d979c7e3feff9db3fde5d89628e2ee3
4
- data.tar.gz: 49a52e216f81e72be6ac0ad601281efa6f171d599a7d91d974a2745e3d6ddfd4
3
+ metadata.gz: f3b4223a54b48ca6e5810cd4ca651928cea2bcba2d5248a3f622823a4b608c0f
4
+ data.tar.gz: e6c737353663a7ac4f354ce6a93b08bf23c767b64b3e53eeb7b2828f3b9dd2f8
5
5
  SHA512:
6
- metadata.gz: 817cd0815232eddfad91e4aa95e2e09a9aa13ed04265e0427644255722f257a4da323e9179cbb37a601ccb4f59190c5ac1358cc242db290c0820377947ac83dd
7
- data.tar.gz: 42eede1664ec537ba56c5d657baefe168e588955d1b29e7e8c2e346977a2d2ef3f9f02413ee0efdf783639a657a9d677eec619b46c799f82668ee46a3ff5ea09
6
+ metadata.gz: 7e50f59ae27956da9f624247f43b94a947f966b4be8092deb53f37f50d2469bfe269eedc27e09a962111c9f15f00ab341af96db6f6d4d0411b7775636ce73dbf
7
+ data.tar.gz: b6c2861e5ab807b77484715322f162ede9f56eab207620070637aa2a3b202841798f96873fbf856350ff2d1d1e9dbe6cf776c10f9f529cdc1c5c97e9405860d0
@@ -15,7 +15,7 @@ From gem version 1.0 onwards this plugin will only have Rails 4+ support. If you
15
15
 
16
16
  Put this in your Gemfile
17
17
 
18
- gem 'active_enum', '~> 1.0.0.pre'
18
+ gem 'active_enum', '~> 1.0.0.rc4'
19
19
 
20
20
  Then generate the config initializer file
21
21
 
@@ -61,7 +61,7 @@ module ActiveEnum
61
61
 
62
62
  # Return enum values in a nested array suitable to pass to a Rails form grouped select helper.
63
63
  def to_grouped_select(group_by)
64
- store.values.group_by { |(_id, _name, meta)| meta.fetch(group_by) }.map { |group, collection|
64
+ store.values.group_by { |(_id, _name, meta)| (meta || {})[group_by] }.map { |group, collection|
65
65
  [ group, collection.map { |(id, name, _meta)| [ name.html_safe, id ] } ]
66
66
  }
67
67
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveEnum
2
- VERSION = '1.0.0.rc4'
2
+ VERSION = '1.0.0.rc5'
3
3
  end
@@ -260,6 +260,18 @@ describe ActiveEnum::Base do
260
260
  [ 'Bar', [ ['Name 2',2] ] ]
261
261
  ])
262
262
  end
263
+
264
+ it 'should group any value missing the group_by key by nil' do
265
+ enum = define_enum do
266
+ value :id => 1, :name => 'Name 1', :category => 'Foo'
267
+ value :id => 2, :name => 'Name 2'
268
+ end
269
+
270
+ expect(enum.to_grouped_select(:category)).to eq([
271
+ [ 'Foo', [ ['Name 1',1] ] ],
272
+ [ nil, [ ['Name 2',2] ] ]
273
+ ])
274
+ end
263
275
  end
264
276
 
265
277
  def define_enum(&block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc4
4
+ version: 1.0.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: 1.3.1
85
85
  requirements: []
86
- rubygems_version: 3.0.6
86
+ rubygems_version: 3.0.3
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Define enum classes in Rails and use them to enumerate ActiveRecord attributes