json_sti 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/json_sti.rb +1 -21
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45ca9be19ec7461034cb8364a5c113c1cb8ac46d3b68e0a7c69de976d0be72a3
|
|
4
|
+
data.tar.gz: 0a210ab819d03d9cdc7f616feb7040121a48960b188b9a07a42dd5fb39ab6115
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41dc2a55f09fe64e1d9f92b0b143337251e24d1169a8f4ad5ce0e9faae84b65cf9cfed4d877816127a1164365c0f2e930208bd0471ab20c582c8d9301f64d643
|
|
7
|
+
data.tar.gz: 70702db7f7700efe0a77b4ccf41cabec6fc36436f29c5bbe0dfc6049cef05c0bebf2943570038cf46975332c303b65763458719b04c4527f23a971cf5807f32a
|
data/lib/json_sti.rb
CHANGED
|
@@ -60,7 +60,7 @@ module JsonSti
|
|
|
60
60
|
presence: false,
|
|
61
61
|
json: {
|
|
62
62
|
message: ->(errors) { errors },
|
|
63
|
-
schema: lambda {
|
|
63
|
+
schema: lambda { self.class::SCHEMA }
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
# a helper similar to ARs `where` only for json fields
|
|
@@ -80,26 +80,6 @@ module JsonSti
|
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
private
|
|
84
|
-
|
|
85
|
-
def cleaned_schema
|
|
86
|
-
schema = self.class::SCHEMA.to_json
|
|
87
|
-
|
|
88
|
-
hash_schema = JSON.parse(schema)
|
|
89
|
-
properties = hash_schema["properties"]
|
|
90
|
-
required = schema['required']
|
|
91
|
-
|
|
92
|
-
properties.each do |property, value|
|
|
93
|
-
unless self.module_data[property]
|
|
94
|
-
unless required.include?(property)
|
|
95
|
-
properties.delete property
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
hash_schema["properties"] = properties
|
|
101
|
-
hash_schema.to_json
|
|
102
|
-
end
|
|
103
83
|
end
|
|
104
84
|
end
|
|
105
85
|
|