schema-model 0.6.8 → 0.6.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/schema/associations/has_many.rb +5 -0
- data/lib/schema/model.rb +5 -1
- data/lib/schema/parsers/common.rb +16 -1
- data/schema-model.gemspec +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: 9f8ccd138c2e52700656fe5bcf67ba518cdfb4c756cf656f821928758872c795
|
4
|
+
data.tar.gz: 90f75db3fc2e4fbae2bf350894b973cea392e652ca0be9b81368f0e9195f6c4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed515074d1a4ec263196f6217c9917f03dadb24dd6dc0b116168198b0c78e73c2cb18f268ed23ea19997d3d06a7fc46b269a51bd42b4e33c38325be0226b86d1
|
7
|
+
data.tar.gz: 58ccd5d4e9902f0dfff14e92222dcb2a6095cbd5bf281004ca738bdbc33618c38c300f76115d25ca91749d3d8b08cd4ec3548c0eb1fdeb43eabb0494b893055e
|
@@ -27,6 +27,11 @@ module Schema
|
|
27
27
|
def #{options[:setter]}(v)
|
28
28
|
#{options[:instance_variable]} = #{name}_schema_creator.create_schemas(self, v)
|
29
29
|
end
|
30
|
+
|
31
|
+
def append_to_#{options[:getter]}(v)
|
32
|
+
#{options[:instance_variable]} ||= []
|
33
|
+
#{options[:instance_variable]} << #{name}_schema_creator.create_schema(self, v)
|
34
|
+
end
|
30
35
|
STR
|
31
36
|
)
|
32
37
|
|
data/lib/schema/model.rb
CHANGED
@@ -129,7 +129,11 @@ STR
|
|
129
129
|
next if opts[:select_filter] && !opts[:select_filter].call(field_name, value, field_options)
|
130
130
|
next if opts[:reject_filter] && opts[:reject_filter].call(field_name, value, field_options)
|
131
131
|
|
132
|
-
|
132
|
+
if value.is_a?(Array)
|
133
|
+
memo[field_name] = value.map { |e| e.as_json(opts) }
|
134
|
+
else
|
135
|
+
memo[field_name] = value.respond_to?(:as_json) ? value.as_json(opts) : value
|
136
|
+
end
|
133
137
|
end
|
134
138
|
end
|
135
139
|
end
|
@@ -48,6 +48,21 @@ module Schema
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
# if the string is empty return nil
|
52
|
+
def parse_string_or_nil(field_name, parsing_errors, value)
|
53
|
+
case value
|
54
|
+
when String
|
55
|
+
value.empty? ? nil : value
|
56
|
+
when ::Hash, ::Array
|
57
|
+
parsing_errors.add(field_name, ::Schema::ParsingErrors::INCOMPATABLE)
|
58
|
+
nil
|
59
|
+
when nil
|
60
|
+
nil
|
61
|
+
else
|
62
|
+
String(value)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
51
66
|
def parse_float(field_name, parsing_errors, value)
|
52
67
|
case value
|
53
68
|
when Float
|
@@ -118,7 +133,7 @@ module Schema
|
|
118
133
|
when Integer, Float
|
119
134
|
value != 0
|
120
135
|
when String
|
121
|
-
BOOLEAN_REGEX.match(value)
|
136
|
+
BOOLEAN_REGEX.match?(value)
|
122
137
|
when nil
|
123
138
|
nil
|
124
139
|
else
|
data/schema-model.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inheritance-helper
|