deco_lite 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +6 -5
- data/lib/deco_lite/field_assignable.rb +2 -2
- data/lib/deco_lite/field_conflictable.rb +6 -6
- data/lib/deco_lite/field_creatable.rb +5 -5
- data/lib/deco_lite/field_name_namespaceable.rb +1 -1
- data/lib/deco_lite/hash_loadable.rb +4 -4
- data/lib/deco_lite/model.rb +4 -4
- data/lib/deco_lite/options_validatable.rb +2 -2
- data/lib/deco_lite/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: 59023b5cc113d4dbeea485aa65b2435ccd6e7e3e3d831f5140cf2ea5a18522c8
|
4
|
+
data.tar.gz: 5f1b3c059301f2485c7eb253e6356cd58e9664092e180472ce688e9e5c4af662
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a7c63990cb650f2528c169a8f423b55ece7c056bc09d076389ad1b02c472bd37ed7c204f0395a609197898f14d5452f81db22f7cc997fc142b8de90b3fd639f
|
7
|
+
data.tar.gz: e8b6dccdecda3a22b70b4a12f2575c01b829816dfdaff56151d2d2d4f7e13fab30818312829778647ce60418a4c17304e23743c7cc05ab5974cfcd20b1e4ece7
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
deco_lite (1.5.
|
4
|
+
deco_lite (1.5.5)
|
5
5
|
activemodel (~> 7.0, >= 7.0.3.1)
|
6
6
|
activesupport (~> 7.0, >= 7.0.3.1)
|
7
7
|
immutable_struct_ex (~> 1.0, >= 1.0.1)
|
@@ -10,9 +10,9 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activemodel (7.0.7)
|
14
|
-
activesupport (= 7.0.7)
|
15
|
-
activesupport (7.0.7)
|
13
|
+
activemodel (7.0.7.2)
|
14
|
+
activesupport (= 7.0.7.2)
|
15
|
+
activesupport (7.0.7.2)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
68
|
rspec-support (~> 3.12.0)
|
69
69
|
rspec-support (3.12.1)
|
70
|
-
rubocop (1.56.
|
70
|
+
rubocop (1.56.2)
|
71
71
|
base64 (~> 0.1.1)
|
72
72
|
json (~> 2.3)
|
73
73
|
language_server-protocol (>= 3.17.0)
|
@@ -105,6 +105,7 @@ GEM
|
|
105
105
|
|
106
106
|
PLATFORMS
|
107
107
|
x86_64-darwin-19
|
108
|
+
x86_64-darwin-21
|
108
109
|
|
109
110
|
DEPENDENCIES
|
110
111
|
bundler (~> 2.2, >= 2.2.17)
|
@@ -9,8 +9,8 @@ module DecoLite
|
|
9
9
|
|
10
10
|
def set_field_values(hash:, field_info:, options:)
|
11
11
|
field_info.each do |name, info|
|
12
|
-
value = get_field_value(hash
|
13
|
-
set_field_value(field_name: name, value
|
12
|
+
value = get_field_value(hash:, field_info: info)
|
13
|
+
set_field_value(field_name: name, value:, options:)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -11,9 +11,9 @@ module DecoLite
|
|
11
11
|
include FieldsOptionable
|
12
12
|
|
13
13
|
def validate_field_conflicts!(field_name:, options:)
|
14
|
-
return unless field_conflict?(field_name
|
14
|
+
return unless field_conflict?(field_name:, options:)
|
15
15
|
|
16
|
-
field_name = field_name_or_field_name_with_namespace
|
16
|
+
field_name = field_name_or_field_name_with_namespace(field_name:, options:)
|
17
17
|
|
18
18
|
raise "Field :#{field_name} conflicts with existing method(s) " \
|
19
19
|
":#{field_name} and/or :#{field_name}=; " \
|
@@ -27,23 +27,23 @@ module DecoLite
|
|
27
27
|
def field_conflict?(field_name:, options:)
|
28
28
|
# If field_name was already added using Model#load, there is only a
|
29
29
|
# conflict if options.strict? is true.
|
30
|
-
return options.strict? if field_names_include?(field_name
|
30
|
+
return options.strict? if field_names_include?(field_name:, options:)
|
31
31
|
|
32
32
|
# If we get here, we know that :field_name does not exist as an
|
33
33
|
# attribute on the model. If the attribute already exists on the
|
34
34
|
# model, this is a conflict because we cannot override an attribute
|
35
35
|
# that already exists on the model
|
36
|
-
attr_accessor_exist?(field_name
|
36
|
+
attr_accessor_exist?(field_name:, options:)
|
37
37
|
end
|
38
38
|
|
39
39
|
def field_names_include?(field_name:, options:)
|
40
|
-
field_name = field_name_or_field_name_with_namespace
|
40
|
+
field_name = field_name_or_field_name_with_namespace(field_name:, options:)
|
41
41
|
|
42
42
|
field_names.include? field_name
|
43
43
|
end
|
44
44
|
|
45
45
|
def attr_accessor_exist?(field_name:, options:)
|
46
|
-
field_name = field_name_or_field_name_with_namespace
|
46
|
+
field_name = field_name_or_field_name_with_namespace(field_name:, options:)
|
47
47
|
|
48
48
|
respond_to?(field_name) || respond_to?(:"#{field_name}=")
|
49
49
|
end
|
@@ -13,19 +13,19 @@ module DecoLite
|
|
13
13
|
return if field_names.blank?
|
14
14
|
|
15
15
|
field_names.each do |field_name|
|
16
|
-
create_field_accessor(field_name
|
16
|
+
create_field_accessor(field_name:, options:)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def create_field_accessor(field_name:, options:)
|
21
|
-
validate_field_name!(field_name
|
22
|
-
validate_field_conflicts!(field_name
|
21
|
+
validate_field_name!(field_name:, options:)
|
22
|
+
validate_field_conflicts!(field_name:, options:)
|
23
23
|
|
24
24
|
# If we want to set a class-level attr_accessor
|
25
25
|
# self.class.attr_accessor(field_name) if field_name.present?
|
26
26
|
|
27
|
-
create_field_getter
|
28
|
-
create_field_setter field_name
|
27
|
+
create_field_getter(field_name:, options:)
|
28
|
+
create_field_setter field_name:, options:
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
@@ -7,7 +7,7 @@ module DecoLite
|
|
7
7
|
def field_name_or_field_name_with_namespace(field_name:, options:)
|
8
8
|
return field_name unless options.namespace?
|
9
9
|
|
10
|
-
field_name_with_namespace(field_name
|
10
|
+
field_name_with_namespace(field_name:, namespace: options.namespace)
|
11
11
|
end
|
12
12
|
|
13
13
|
def field_name_with_namespace(field_name:, namespace:)
|
@@ -17,13 +17,13 @@ module DecoLite
|
|
17
17
|
|
18
18
|
return {} if hash.blank?
|
19
19
|
|
20
|
-
load_service_options = merge_with_load_service_options
|
21
|
-
load_service.execute(hash
|
20
|
+
load_service_options = merge_with_load_service_options(deco_lite_options:)
|
21
|
+
load_service.execute(hash:, options: load_service_options).tap do |service_hash|
|
22
22
|
service_hash.each_pair do |field_name, value|
|
23
|
-
create_field_accessor field_name
|
23
|
+
create_field_accessor field_name:, options: deco_lite_options
|
24
24
|
yield field_name if block_given?
|
25
25
|
field_names << field_name unless field_names.include? field_name
|
26
|
-
set_field_value(field_name
|
26
|
+
set_field_value(field_name:, value:, options: deco_lite_options)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/deco_lite/model.rb
CHANGED
@@ -34,9 +34,9 @@ module DecoLite
|
|
34
34
|
|
35
35
|
hash ||= {}
|
36
36
|
|
37
|
-
load_hash!(hash: auto_attr_accessors, options
|
37
|
+
load_hash!(hash: auto_attr_accessors, options:, add_loaded_fields: false) if auto_attr_accessors?
|
38
38
|
|
39
|
-
load_hash!(hash
|
39
|
+
load_hash!(hash:, options:) if hash.present?
|
40
40
|
end
|
41
41
|
|
42
42
|
validate :validate_required_fields
|
@@ -52,7 +52,7 @@ module DecoLite
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def load!(hash:, options: {})
|
55
|
-
load_hash! hash
|
55
|
+
load_hash! hash:, options:
|
56
56
|
end
|
57
57
|
|
58
58
|
private
|
@@ -70,7 +70,7 @@ module DecoLite
|
|
70
70
|
# options while loading, but also provide option customization
|
71
71
|
# of options when needed.
|
72
72
|
options = Options.with_defaults(options, defaults: self.options)
|
73
|
-
load_hash(hash
|
73
|
+
load_hash(hash:, deco_lite_options: options) do |loaded_field|
|
74
74
|
loaded_fields << loaded_field if add_loaded_fields
|
75
75
|
end
|
76
76
|
|
@@ -14,9 +14,9 @@ module DecoLite
|
|
14
14
|
def validate_options!(options:)
|
15
15
|
raise ArgumentError, 'options is not a Hash' unless options.is_a? Hash
|
16
16
|
|
17
|
-
validate_options_present!
|
17
|
+
validate_options_present!(options:)
|
18
18
|
|
19
|
-
validate_option_keys!
|
19
|
+
validate_option_keys!(options:)
|
20
20
|
validate_option_fields! fields: options[OPTION_FIELDS]
|
21
21
|
validate_option_namespace! namespace: options[OPTION_NAMESPACE]
|
22
22
|
end
|
data/lib/deco_lite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deco_lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gene M. Angelo, Jr.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|