activejsonmodel 0.1.3 → 0.1.4
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/active_json_model/array.rb +15 -3
- data/lib/active_json_model/model.rb +15 -3
- data/lib/active_json_model/version.rb +1 -1
- data/lib/active_json_model.rb +4 -2
- 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: e7dc0c113f2d8bd650b237c5888d8cfdc8e0bb7747dc994eacc88bed98ed86fd
|
4
|
+
data.tar.gz: 88ef99a717976d7ba37de7523f101fbff1f49ec848bd6e216f33f7a33482d530
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09bb083c925bed9b1efdf6fa7b343cb85e3b7ac5419d614218590980657bce605ff444a1012680c20e97639ae535ebc0a413f7b2eb51f90f8ad5518a11f7a0eb'
|
7
|
+
data.tar.gz: 74455ab06735cfb9b27d68cbe44d6457cb968b3eeaae2dc79e691f1bc5a36f161aa015403cf6effdd0f970b8d1d2f7dc25e46f7637a0ec5b74ad0746f12e3521
|
@@ -6,7 +6,7 @@ require 'active_support'
|
|
6
6
|
require_relative './json_attribute'
|
7
7
|
require_relative './after_load_callback'
|
8
8
|
|
9
|
-
if
|
9
|
+
if Gem.find_files("active_record").any?
|
10
10
|
require_relative './active_record_type'
|
11
11
|
require_relative './active_record_encrypted_type'
|
12
12
|
end
|
@@ -238,7 +238,11 @@ module ActiveJsonModel
|
|
238
238
|
#
|
239
239
|
# Note that this array_data would be stored as jsonb in the database
|
240
240
|
def attribute_type
|
241
|
-
|
241
|
+
if Gem.find_files("active_record").any?
|
242
|
+
@attribute_type ||= ::ActiveJsonModel::ActiveRecordType.new(self)
|
243
|
+
else
|
244
|
+
raise RuntimeError.new('ActiveRecord must be installed to use attribute_type')
|
245
|
+
end
|
242
246
|
end
|
243
247
|
|
244
248
|
# Allow this model to be used as ActiveRecord attribute type in Rails 5+.
|
@@ -253,7 +257,15 @@ module ActiveJsonModel
|
|
253
257
|
# Note that this array_data would be stored as a string in the database, encrypted using
|
254
258
|
# a symmetric key at the application level.
|
255
259
|
def encrypted_attribute_type
|
256
|
-
|
260
|
+
if Gem.find_files("active_record").any?
|
261
|
+
if Gem.find_files("symmetric-encryption").any?
|
262
|
+
@encrypted_attribute_type ||= ::ActiveJsonModel::ActiveRecordEncryptedType.new(self)
|
263
|
+
else
|
264
|
+
raise RuntimeError.new('symmetric-encryption must be installed to use attribute_type')
|
265
|
+
end
|
266
|
+
else
|
267
|
+
raise RuntimeError.new('active_record must be installed to use attribute_type')
|
268
|
+
end
|
257
269
|
end
|
258
270
|
end
|
259
271
|
|
@@ -5,7 +5,7 @@ require 'json'
|
|
5
5
|
require_relative './json_attribute'
|
6
6
|
require_relative './after_load_callback'
|
7
7
|
|
8
|
-
if
|
8
|
+
if Gem.find_files("active_record").any?
|
9
9
|
require_relative './active_record_type'
|
10
10
|
require_relative './active_record_encrypted_type'
|
11
11
|
end
|
@@ -275,7 +275,11 @@ module ActiveJsonModel
|
|
275
275
|
#
|
276
276
|
# Note that this data would be stored as jsonb in the database
|
277
277
|
def attribute_type
|
278
|
-
|
278
|
+
if Gem.find_files("active_record").any?
|
279
|
+
@attribute_type ||= ::ActiveJsonModel::ActiveRecordType.new(self)
|
280
|
+
else
|
281
|
+
raise RuntimeError.new('ActiveRecord must be installed to use attribute_type')
|
282
|
+
end
|
279
283
|
end
|
280
284
|
|
281
285
|
# Allow this model to be used as ActiveRecord attribute type in Rails 5+.
|
@@ -290,7 +294,15 @@ module ActiveJsonModel
|
|
290
294
|
# Note that this data would be stored as a string in the database, encrypted using
|
291
295
|
# a symmetric key at the application level.
|
292
296
|
def encrypted_attribute_type
|
293
|
-
|
297
|
+
if Gem.find_files("active_record").any?
|
298
|
+
if Gem.find_files("symmetric-encryption").any?
|
299
|
+
@encrypted_attribute_type ||= ::ActiveJsonModel::ActiveRecordEncryptedType.new(self)
|
300
|
+
else
|
301
|
+
raise RuntimeError.new('symmetric-encryption must be installed to use attribute_type')
|
302
|
+
end
|
303
|
+
else
|
304
|
+
raise RuntimeError.new('active_record must be installed to use attribute_type')
|
305
|
+
end
|
294
306
|
end
|
295
307
|
end
|
296
308
|
|
data/lib/active_json_model.rb
CHANGED
@@ -4,8 +4,10 @@ require "active_support"
|
|
4
4
|
module ActiveJsonModel
|
5
5
|
extend ActiveSupport::Autoload
|
6
6
|
|
7
|
-
autoload :
|
8
|
-
autoload :
|
7
|
+
autoload :ActiveRecordEncryptedType, "active_json_model/active_record_encrypted_type" unless Gem.find_files("active_record").none? || Gem.find_files("symmetric-encryption").none?
|
8
|
+
autoload :ActiveRecordType, "active_json_model/active_record_type" unless Gem.find_files("active_record").none?
|
9
9
|
autoload :Array, "active_json_model/array"
|
10
|
+
autoload :Model, "active_json_model/model"
|
10
11
|
autoload :Utils, "active_json_model/utils"
|
12
|
+
autoload :VERSION, "active_json_model/version"
|
11
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejsonmodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Morlok
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|