store_model 0.5.2 → 0.5.3

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
  SHA256:
3
- metadata.gz: ddf27da9ed2536f94b6363448b5198695e8c15113b94e4e160a10980a8709532
4
- data.tar.gz: f508d45e6a30c2634a89fdbd8204643aa597f1c879958314bb0c83b4fe3fd27f
3
+ metadata.gz: af63b9a0cfb1ce85d4d2d81418cf102a9c32470cedce2191fb86b07970e1e73a
4
+ data.tar.gz: 9b109d3e56bbaad016f65b9c7db4ed3aa49091baae470546d94ebf1159bea081
5
5
  SHA512:
6
- metadata.gz: fccc4d5dee04b782758ada583a9a840b585805786869912a1d82e50a8df5dcfb682afc97b1dffe45961640a095395f1da4f3b27c0e94afeddc59de5a218c658e
7
- data.tar.gz: ad0e9c6f11accc117b45a9647d525ad9a19acc47704d22261129e46ec648461b77585e3d4ff828ad3a00b46bf3b6968789af97a2ac8e1789d8c965c9da034c98
6
+ metadata.gz: 485914961ef2a6c0d55705172d7f6251c1baf8802b5add498b4ce413f327926170748b008109fabae501b7c47a8293b131c79f95c90daa1ef39b59125ddbcd56
7
+ data.tar.gz: 3e66a2591f425a77789bb3eb45922d9dc6c5e3c07e6902df71a38a091f808c5904052196b9f21dd421cb5646e6751d5fea910b57e232b014c78c111c542014cf
@@ -69,15 +69,23 @@ module StoreModel
69
69
  # rubocop:disable Style/RescueModifier
70
70
  def decode_and_initialize(array_value)
71
71
  decoded = ActiveSupport::JSON.decode(array_value) rescue []
72
- decoded.map { |attributes| @model_klass.new(attributes) }
72
+ decoded.map { |attributes| cast_model_type_value(attributes) }
73
73
  end
74
74
  # rubocop:enable Style/RescueModifier
75
75
 
76
76
  def ensure_model_class(array)
77
77
  array.map do |object|
78
- object.is_a?(@model_klass) ? object : @model_klass.new(object)
78
+ object.is_a?(@model_klass) ? object : cast_model_type_value(object)
79
79
  end
80
80
  end
81
+
82
+ def cast_model_type_value(value)
83
+ model_klass_type.cast_value(value)
84
+ end
85
+
86
+ def model_klass_type
87
+ @model_klass_type ||= @model_klass.to_type
88
+ end
81
89
  end
82
90
  end
83
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoreModel # :nodoc:
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-23 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails