json_mapper 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/json_mapper.gemspec +2 -2
  3. data/lib/json_mapper.rb +23 -5
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{json_mapper}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Trond Arve Nordheim"]
12
- s.date = %q{2010-08-09}
12
+ s.date = %q{2010-08-10}
13
13
  s.email = %q{tanordheim@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -9,10 +9,27 @@ module JSONMapper
9
9
  base.instance_variable_set("@attributes", {})
10
10
  base.instance_variable_set("@json_data", {})
11
11
  base.extend ClassMethods
12
+ base.send :include, InstanceMethods
13
+ end
14
+
15
+ module InstanceMethods
16
+
17
+ def json_data
18
+ self.class.json_data
19
+ end
20
+
12
21
  end
13
22
 
14
23
  module ClassMethods
15
24
 
25
+ def json_data=(data)
26
+ @json_data[to_s] = data
27
+ end
28
+
29
+ def json_data
30
+ @json_data[to_s]
31
+ end
32
+
16
33
  def json_attribute(name, *args)
17
34
 
18
35
  source_attributes, type, options = extract_attribute_data(name, *args)
@@ -39,9 +56,9 @@ module JSONMapper
39
56
  @attributes[to_s] || []
40
57
  end
41
58
 
42
- def json_data
43
- @json_data[to_s] || []
44
- end
59
+ # def json_data
60
+ # @json_data[to_s] || []
61
+ # end
45
62
 
46
63
  def parse(data, options = {})
47
64
 
@@ -62,7 +79,8 @@ module JSONMapper
62
79
  def parse_json(json)
63
80
 
64
81
  # Set the JSON data for this instance
65
- @json_data[to_s] = json
82
+ self.json_data = json
83
+ # @json_data[to_s] = json
66
84
 
67
85
  # Create a new instance of ourselves
68
86
  instance = new
@@ -229,7 +247,7 @@ module JSONMapper
229
247
 
230
248
  # If no mapping could be found and this attribute is potentially
231
249
  # self-referencing, return the current JSON data as the mapped value
232
- return json_data if attribute.self_referential?
250
+ return self.json_data if attribute.self_referential?
233
251
 
234
252
  return nil
235
253
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_mapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Trond Arve Nordheim
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-09 00:00:00 +02:00
18
+ date: 2010-08-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency