smart_enum 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_enum/associations.rb +2 -2
- data/lib/smart_enum/version.rb +1 -1
- 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: 4d5e1b7ef5e308f04977da423a507a2b4410f37fd5598f1bf3e91ca1a62eccb6
|
4
|
+
data.tar.gz: 75ec6c25b5b250d087f32ced6f592010c0f58d4291edabf61d4699801f6c3d3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb70f0475bb263cd313e64d83b953d0630ddc0667686658eaf3be2b71a428db3f31e6a3937198ca26a4f7a1b520c41306b7b6048bf3e84da5ee750e0057c87c2
|
7
|
+
data.tar.gz: 2f780b170aaab8ee794096c65767a1543dcbcdf5aa88841f39e80bee594c0fd59527a2d49c30c101943f7b8ef6b589a78adb3a0738d4f0c286fb49f9945e08e7
|
@@ -57,13 +57,13 @@ class SmartEnum
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def belongs_to_enum(association_name, class_name: nil, foreign_key: nil)
|
60
|
+
def belongs_to_enum(association_name, class_name: nil, foreign_key: nil, when_nil: nil)
|
61
61
|
association_name = association_name.to_sym
|
62
62
|
association = Association.new(self, association_name, class_name: class_name, foreign_key: foreign_key)
|
63
63
|
enum_associations[association_name] = association
|
64
64
|
|
65
65
|
define_method(association_name) do
|
66
|
-
id_to_find = self.public_send(association.foreign_key)
|
66
|
+
id_to_find = self.public_send(association.foreign_key) || when_nil
|
67
67
|
association.association_class[id_to_find]
|
68
68
|
end
|
69
69
|
|
data/lib/smart_enum/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Brasic
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.7.
|
68
|
+
rubygems_version: 2.7.6
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: Enums to replace database lookup tables
|