enumbler 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/enumbler/enabler.rb +13 -2
- data/lib/enumbler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96cdeb24ac43db515f90d6cf857e497281066c7dad0f5c2cf93d3aada54265dc
|
4
|
+
data.tar.gz: 13247cd26aa94ad10fe7f739fc8c3690d6e3702c59d77caceb80242a9df722d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57cf510621d28df43bca6d5e7715e6bd9c1452a7a7457a1fd6ef3ae0f47425927deec6bc16e34dd2ccb94781cdb37f358d62825c8c64aed0294ffcd247fd6a93
|
7
|
+
data.tar.gz: 007d1e7c93fcf129ec0b13d037edd045e4e18b9d453a6dadc2381425a73f9b64424a83e4d976b0bd316a593ccf3c5e9d3f986c1cbb2bed35f7a9cb1f4dfc94b5
|
data/Gemfile.lock
CHANGED
data/lib/enumbler/enabler.rb
CHANGED
@@ -58,12 +58,14 @@ module Enumbler
|
|
58
58
|
# @param **attributes [Hash] optional: additional attributes and values that
|
59
59
|
# will be saved to the database for this enumble record
|
60
60
|
def enumble(enum, id, label: nil, **attributes)
|
61
|
+
raise_error_if_model_does_not_support_attributes(attributes)
|
62
|
+
|
63
|
+
id = validate_id_is_numeric(enum, id)
|
64
|
+
|
61
65
|
@enumbles ||= Enumbler::Collection.new
|
62
66
|
@enumbled_model = self
|
63
67
|
@enumbler_label_column_name ||= :label
|
64
68
|
|
65
|
-
raise_error_if_model_does_not_support_attributes(attributes)
|
66
|
-
|
67
69
|
enumble = Enumble.new(enum, id, label: label, label_column_name: @enumbler_label_column_name, **attributes)
|
68
70
|
|
69
71
|
if @enumbles.include?(enumble)
|
@@ -313,6 +315,15 @@ module Enumbler
|
|
313
315
|
end
|
314
316
|
end
|
315
317
|
|
318
|
+
# I accidentally forgot to provide an id one time and it was confusing as
|
319
|
+
# the last argument became the hash of options. This should help.
|
320
|
+
def validate_id_is_numeric(enum, id)
|
321
|
+
Integer(id)
|
322
|
+
rescue ArgumentError, TypeError
|
323
|
+
raise Enumbler::Error,
|
324
|
+
"You must provide a numeric primary key, like: `enumble :#{enum}, 1 `"
|
325
|
+
end
|
326
|
+
|
316
327
|
def raise_error_if_model_does_not_support_attributes(attributes)
|
317
328
|
return if attributes.blank?
|
318
329
|
|
data/lib/enumbler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damon Timm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|