activemodel-datastore 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/active_model/datastore.rb +12 -6
- data/lib/active_model/datastore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 798ea7d0389b4ebe382843a0392d3c1d2a9d2d9b
|
4
|
+
data.tar.gz: ad21cf50902c04a3277eab704e5a0b9c81bb8db5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2323ec3937aca9cf5bd817f7788d0990fe4ba965ff0b03c5421cd0c662e5308a6caaab4daf5965d5c8b719d7117dc34fd9ab6bf27b8d1cb61d007fe02adfa52
|
7
|
+
data.tar.gz: 2d3660d111a2fbbb3081861b4657a016d0decd16ba966a1e55212f20653f2914a2cb9a671f298a5e9acd469138cfe063f8c7362c08a103452adaf95ae1d61752
|
data/CHANGELOG.md
CHANGED
@@ -121,7 +121,7 @@ module ActiveModel::Datastore
|
|
121
121
|
included do
|
122
122
|
private_class_method :query_options, :query_sort, :query_property_filter, :find_all_entities
|
123
123
|
define_model_callbacks :save, :update, :destroy
|
124
|
-
attr_accessor :id, :parent_key_id
|
124
|
+
attr_accessor :id, :parent_key_id, :entity_property_values
|
125
125
|
end
|
126
126
|
|
127
127
|
def entity_properties
|
@@ -361,11 +361,9 @@ module ActiveModel::Datastore
|
|
361
361
|
#
|
362
362
|
def from_entity(entity)
|
363
363
|
return if entity.nil?
|
364
|
-
model_entity =
|
365
|
-
model_entity.
|
366
|
-
|
367
|
-
model_entity.parent_key_id = entity.key.parent.id if entity.key.parent.present?
|
368
|
-
entity.properties.to_hash.each do |name, value|
|
364
|
+
model_entity = build_model(entity)
|
365
|
+
model_entity.entity_property_values = entity.properties.to_h
|
366
|
+
entity.properties.to_h.each do |name, value|
|
369
367
|
model_entity.send "#{name}=", value if model_entity.respond_to? "#{name}="
|
370
368
|
end
|
371
369
|
model_entity.reload!
|
@@ -489,5 +487,13 @@ module ActiveModel::Datastore
|
|
489
487
|
keys.map { |key| key.parent = parent } if parent.present?
|
490
488
|
retry_on_exception { CloudDatastore.dataset.find_all keys }
|
491
489
|
end
|
490
|
+
|
491
|
+
def build_model(entity)
|
492
|
+
model_entity = new
|
493
|
+
model_entity.id = entity.key.id unless entity.key.id.nil?
|
494
|
+
model_entity.id = entity.key.name unless entity.key.name.nil?
|
495
|
+
model_entity.parent_key_id = entity.key.parent.id if entity.key.parent.present?
|
496
|
+
model_entity
|
497
|
+
end
|
492
498
|
end
|
493
499
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-datastore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryce McLean
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|