ninja-model 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,11 +4,34 @@ module NinjaModel
4
4
 
5
5
  module InstanceMethods
6
6
  def marshal_dump
7
- ActiveSupport::JSON.encode(attributes)
7
+ 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
14
+ r[k.to_s] = instance_variable_get(k)
15
+ end
16
+ r
17
+ }
18
+ h[:attributes] = {}
19
+ @attributes.each do |k, v|
20
+ h[:attributes][k] = ActiveSupport::JSON.encode(v)
21
+ end
22
+ ActiveSupport::JSON.encode(h)
8
23
  end
9
24
 
10
25
  def marshal_load(data)
11
- self.instantiate(ActiveSupport::JSON.decode(data))
26
+ h = ActiveSupport::JSON.decode(data)
27
+ @attributes = {}
28
+ h.each do |k, v|
29
+ if k.eql?(:attributes)
30
+ @attributes[k] = ActiveSupport::JSON.decode(v)
31
+ else
32
+ instance_variable_set(k, v)
33
+ end
34
+ end
12
35
  end
13
36
  end
14
37
  end
@@ -1,3 +1,3 @@
1
1
  module NinjaModel
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = %q{http://github.com/t3hpr1m3/ninja-model.git}
12
12
  s.summary = %q{Pseudo-ORM for Ruby}
13
13
  s.description = %q{Pseudo-ORM for Ruby/Rails with an ActiveRecord-like interface}
14
+ s.license = %q{MIT}
14
15
 
15
16
  s.rubyforge_project = s.name
16
17
 
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.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-07 00:00:00.000000000 Z
12
+ date: 2013-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -270,7 +270,8 @@ files:
270
270
  - spec/support/factories/user.rb
271
271
  - spec/support/matchers/convert.rb
272
272
  homepage: http://github.com/t3hpr1m3/ninja-model.git
273
- licenses: []
273
+ licenses:
274
+ - MIT
274
275
  post_install_message:
275
276
  rdoc_options: []
276
277
  require_paths:
@@ -283,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
283
284
  version: '0'
284
285
  segments:
285
286
  - 0
286
- hash: 651932753
287
+ hash: 861620109
287
288
  required_rubygems_version: !ruby/object:Gem::Requirement
288
289
  none: false
289
290
  requirements:
@@ -292,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
293
  version: '0'
293
294
  segments:
294
295
  - 0
295
- hash: 651932753
296
+ hash: 861620109
296
297
  requirements: []
297
298
  rubyforge_project: ninja-model
298
299
  rubygems_version: 1.8.24