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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e463987e83057901c6622e91ed81f2b6c87e835
4
- data.tar.gz: 2500a1f4714efeeecaa2ba0c6d5f46dd36a09ac9
3
+ metadata.gz: 798ea7d0389b4ebe382843a0392d3c1d2a9d2d9b
4
+ data.tar.gz: ad21cf50902c04a3277eab704e5a0b9c81bb8db5
5
5
  SHA512:
6
- metadata.gz: e18f47242c6c6e480845b24dd8aacb42477602ef815fb2b7496112b280f49bb48b3b15314b788981f34a613a74132c3ae36ae0a22d5d38403814ab93eb7c795d
7
- data.tar.gz: 351cf7661a783efb53362838e045a1c4a7d1dfa45c4b434c35853c5a8fab9557b7ca444a68d4c0da646eb634da20d322b0c5fd619f3168def4a8fe04d2dd7c0f
6
+ metadata.gz: d2323ec3937aca9cf5bd817f7788d0990fe4ba965ff0b03c5421cd0c662e5308a6caaab4daf5965d5c8b719d7117dc34fd9ab6bf27b8d1cb61d007fe02adfa52
7
+ data.tar.gz: 2d3660d111a2fbbb3081861b4657a016d0decd16ba966a1e55212f20653f2914a2cb9a671f298a5e9acd469138cfe063f8c7362c08a103452adaf95ae1d61752
@@ -1,3 +1,8 @@
1
+ ### 0.2.2 / 2017-04-27
2
+
3
+ * now store a hash of entity properties during entity to model conversion
4
+ * preparing for CarrierWave file upload support
5
+
1
6
  ### 0.2.1 / 2017-04-25
2
7
 
3
8
  * adding support for boolean types to format_property_value
@@ -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 = new
365
- model_entity.id = entity.key.id unless entity.key.id.nil?
366
- model_entity.id = entity.key.name unless entity.key.name.nil?
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
@@ -1,5 +1,5 @@
1
1
  module ActiveModel
2
2
  module Datastore
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  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.1
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-25 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel