dm-metamapper 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,15 +40,15 @@ module DataMapper
40
40
 
41
41
  def key_to_parent
42
42
  many_to_one.inject({}) do |hash, (r,m)|
43
- hash[m.child_key.first.name] = decolonize(m.parent_model_name.to_const_string)
43
+ hash[m.child_key.first.name] = decolonize(m.parent_model_name)
44
44
  hash
45
45
  end
46
46
  end
47
47
 
48
48
  def child_key(child_model)
49
- child_model.relationships.select {|m|
49
+ child_model.relationships.find {|k,m|
50
50
  m.class.name == 'DataMapper::Associations::ManyToOne::Relationship' && m.parent_model_name == model.name
51
- }.first.child_key.first.name.to_s
51
+ }[1].child_key.first.name.to_s
52
52
  end
53
53
 
54
54
  def output_path(model, template)
@@ -64,29 +64,30 @@ module DataMapper
64
64
 
65
65
  def many_to_one
66
66
  return unless model
67
- @many_to_one ||= model.relationships.select {|m|
67
+ @many_to_one ||= model.relationships.select {|k,m|
68
68
  m.class.name == 'DataMapper::Associations::ManyToOne::Relationship'
69
69
  }
70
+
70
71
  #in case of ruby < 1.9
71
- if Array === @many_to_one
72
- temp = @many_to_one
73
- @many_to_one = {}
74
- temp.each{|t| @many_to_one[t.name] = t}
75
- end
72
+ # if Array === @many_to_one
73
+ # temp = @many_to_one
74
+ # @many_to_one = {}
75
+ # temp.each{|t| @many_to_one[t.name] = t}
76
+ # end
76
77
 
77
78
  @many_to_one
78
79
  end
79
80
  def one_to_many
80
81
  return unless model
81
- @one_to_many ||= model.relationships.select {|m|
82
+ @one_to_many ||= model.relationships.select {|k,m|
82
83
  m.class.name == 'DataMapper::Associations::OneToMany::Relationship'
83
84
  }
84
85
  #in case of ruby < 1.9
85
- if Array === @one_to_many
86
- temp = @one_to_many
87
- @one_to_many = {}
88
- temp.each{|t| @one_to_many[t.name] = t}
89
- end
86
+ # if Array === @one_to_many
87
+ # temp = @one_to_many
88
+ # @one_to_many = {}
89
+ # temp.each{|t| @one_to_many[t.name] = t}
90
+ # end
90
91
 
91
92
  @one_to_many
92
93
  end
@@ -1,6 +1,6 @@
1
1
  module DataMapper
2
2
  module MetaMapper
3
- VERSION = "0.2.8" unless defined?(::DataMapper::MetaMapper::VERSION)
3
+ VERSION = "0.2.9" unless defined?(::DataMapper::MetaMapper::VERSION)
4
4
  end
5
5
 
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-metamapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 8
10
- version: 0.2.8
9
+ - 9
10
+ version: 0.2.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonah Honeyman
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-07-14 00:00:00 Z
19
+ date: 2012-07-23 00:00:00 Z
20
20
  dependencies: []
21
21
 
22
22
  description: C++ API for databases created with DM. Hard typing, compile time checked queries.