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 +4 -4
- data/README.rdoc +1 -1
- data/lib/active_enum/base.rb +1 -1
- data/lib/active_enum/version.rb +1 -1
- data/spec/active_enum/base_spec.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3b4223a54b48ca6e5810cd4ca651928cea2bcba2d5248a3f622823a4b608c0f
|
4
|
+
data.tar.gz: e6c737353663a7ac4f354ce6a93b08bf23c767b64b3e53eeb7b2828f3b9dd2f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e50f59ae27956da9f624247f43b94a947f966b4be8092deb53f37f50d2469bfe269eedc27e09a962111c9f15f00ab341af96db6f6d4d0411b7775636ce73dbf
|
7
|
+
data.tar.gz: b6c2861e5ab807b77484715322f162ede9f56eab207620070637aa2a3b202841798f96873fbf856350ff2d1d1e9dbe6cf776c10f9f529cdc1c5c97e9405860d0
|
data/README.rdoc
CHANGED
data/lib/active_enum/base.rb
CHANGED
@@ -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
|
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
|
data/lib/active_enum/version.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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
|