ninja-model 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,33 +4,27 @@ module NinjaModel
4
4
 
5
5
  module InstanceMethods
6
6
  def marshal_dump
7
+ exceptions = %w(@association_cache @aggregation_cache @attributes)
7
8
  h = self.instance_variables.inject({}) { |r, k|
8
- if k.to_s.eql?('@attributes')
9
- r[:attributes] = @attributes.inject({}) { |a, (k, v)|
10
- a[k] = ActiveSupport::JSON.encode(v)
11
- a
12
- }
13
- else
9
+ unless exceptions.include?(k.to_s)
14
10
  r[k.to_s] = instance_variable_get(k)
15
11
  end
16
12
  r
17
13
  }
18
- h[:attributes] = {}
19
- @attributes.each do |k, v|
20
- h[:attributes][k] = ActiveSupport::JSON.encode(v)
21
- end
14
+ h['@attributes'] = @attributes.inject({}) { |a, (k, v)|
15
+ a[k] = ActiveSupport::JSON.encode(v)
16
+ a
17
+ }
22
18
  ActiveSupport::JSON.encode(h)
23
19
  end
24
20
 
25
21
  def marshal_load(data)
26
22
  h = ActiveSupport::JSON.decode(data)
27
23
  h.each do |k, v|
28
- if k.to_s.eql?('attributes')
29
- @attributes = v
30
- else
31
- instance_variable_set(k, v)
32
- end
24
+ instance_variable_set(k, v)
33
25
  end
26
+ @association_cache = {}
27
+ @aggregation_cache = {}
34
28
  end
35
29
  end
36
30
  end
@@ -1,3 +1,3 @@
1
1
  module NinjaModel
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ninja-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -284,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
284
284
  version: '0'
285
285
  segments:
286
286
  - 0
287
- hash: 834533805
287
+ hash: -180923263
288
288
  required_rubygems_version: !ruby/object:Gem::Requirement
289
289
  none: false
290
290
  requirements:
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  version: '0'
294
294
  segments:
295
295
  - 0
296
- hash: 834533805
296
+ hash: -180923263
297
297
  requirements: []
298
298
  rubyforge_project: ninja-model
299
299
  rubygems_version: 1.8.24