dm-maker 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -39,6 +39,9 @@ associations:
39
39
  manufacturer:
40
40
  name: Knight Industries
41
41
 
42
+ (note that associated instances can include a `$class` attribute, which might be
43
+ required due to Single Table Inheritance)
44
+
42
45
  ERB expansion:
43
46
 
44
47
  Person:
data/README.md CHANGED
@@ -39,6 +39,9 @@ associations:
39
39
  manufacturer:
40
40
  name: Knight Industries
41
41
 
42
+ (note that associated instances can include a `$class` attribute, which might be
43
+ required due to Single Table Inheritance)
44
+
42
45
  ERB expansion:
43
46
 
44
47
  Person:
@@ -44,14 +44,18 @@ module DataMapper
44
44
  assoc_class = klass.new. # XXX: hacky
45
45
  send(rel_name).relationship.child_model
46
46
  value = value.map { |d|
47
- if custom_class = d.delete("class") # TODO: document
47
+ if custom_class = d.delete("$class") # TODO: document and test
48
48
  assoc_class = custom_class.constantize
49
49
  end
50
50
  create_instance(assoc_class, d, cache)
51
51
  }
52
52
  elsif REL_TYPES[:to_one].include? rel.class
53
- assoc_class = (rel.child_model == klass or klass < rel.child_model) ?
54
- rel.parent_model : rel.child_model
53
+ if custom_class = d.delete("$class") # TODO: document and test
54
+ assoc_class = custom_class.constantize
55
+ else
56
+ assoc_class = (rel.child_model == klass or klass < rel.child_model) ?
57
+ rel.parent_model : rel.child_model
58
+ end
55
59
  value = create_instance(assoc_class, value, cache)
56
60
  end
57
61
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module DataMapper
4
4
  module Maker
5
- VERSION = "1.0.1"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-maker
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 0
9
8
  - 1
10
- version: 1.0.1
9
+ - 0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - FND
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-14 00:00:00 Z
18
+ date: 2011-11-16 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: dm-core