swifter_enum 0.9.2 → 0.9.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c619ac4afac5bcbad7b49e421d04faa75bd558611297effa54c992a9509b7d7f
|
4
|
+
data.tar.gz: 2fa59214a51e2417b6834362fcce525f5ca10a4fdf962261576252a0f6f6071f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02d2882937c808e0c9c652ee7cf85cbea7a0d4425e33e7656718ac906bd475a2173ab5ec8d0f79d1a61b9ef8f634d76696429eac7500e7da33d039adb52a7038
|
7
|
+
data.tar.gz: 5f4186f334a5f9fedb4e670a8f0dea82872e9d9733e96f44c0f9867438effa96d1408b85fa2f13d628487cf922ca5ee763f2c36e2c2dc963ce0eea431cf7fb1e
|
data/lib/swifter_enum/base.rb
CHANGED
@@ -6,10 +6,10 @@ module SwifterEnum
|
|
6
6
|
def set_values(input)
|
7
7
|
case input
|
8
8
|
when Hash
|
9
|
-
@values = input
|
9
|
+
@values = input.freeze
|
10
10
|
when Array
|
11
11
|
validate_array_elements!(input)
|
12
|
-
@values = input.map { |item| [item.to_sym, item.to_s] }.to_h
|
12
|
+
@values = input.map { |item| [item.to_sym, item.to_s] }.to_h.freeze
|
13
13
|
else
|
14
14
|
raise ArgumentError, "Input must be a Hash or an Array of symbols or strings"
|
15
15
|
end
|
@@ -10,7 +10,7 @@ class <%= class_name %>Enum < SwifterEnum::Base
|
|
10
10
|
#if you're using an array of symbols (or strings), then your database column should be of string type
|
11
11
|
# e.g. set_values [:active,:passive]
|
12
12
|
|
13
|
-
set_values
|
13
|
+
set_values ##Your Values Here##
|
14
14
|
|
15
15
|
# you can now define methods on the enum
|
16
16
|
# this would allow you to access YourModel.<%= file_name %>.squared
|
data/lib/swifter_enum/version.rb
CHANGED