datamapa 0.0.4 → 0.0.5

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.
@@ -1,3 +1,3 @@
1
1
  module DataMapa
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/datamapa.rb CHANGED
@@ -73,14 +73,14 @@ module DataMapa
73
73
  @simple_attr.each do |attr|
74
74
  setter = "#{attr.to_s.chomp('?')}="
75
75
  object.send(setter, relational.send(attr))
76
- end
76
+ end if @simple_attr
77
77
  end
78
78
 
79
79
  def r2o_ref(relational, object)
80
80
  @ref_attr.each do |attr, mapper|
81
81
  setter = "#{attr}="
82
82
  object.send(setter, mapper.to_model(relational.send(attr)))
83
- end
83
+ end if @ref_attr
84
84
  end
85
85
 
86
86
  def r2o_collection(ar, model, attributes)
@@ -94,14 +94,14 @@ module DataMapa
94
94
  def o2r_attr(object, relational)
95
95
  @simple_attr.each do |attr|
96
96
  relational.send("#{attr.to_s.chomp('?')}=", object.send(attr))
97
- end
97
+ end if @simple_attr
98
98
  end
99
99
 
100
100
  def o2r_ref(object, relational)
101
101
  @ref_attr.each_key do |attr|
102
102
  ref = object.send(attr)
103
103
  relational.send("#{attr.to_s.chomp('?')}_id=", ref.id) unless ref.nil?
104
- end
104
+ end if @ref_attr
105
105
  end
106
106
 
107
107
  def o2r_collection(object, relational, attributes)
@@ -20,9 +20,9 @@ describe DataMapa do
20
20
 
21
21
  active_record_class ar_class
22
22
  model_constructor model_class.method(:new)
23
- simple_attr attributes[:simple] || []
24
- ref_attr attributes[:ref] || {}
25
- collection_attr attributes[:collection] || {}
23
+ simple_attr attributes[:simple] if attributes[:simple]
24
+ ref_attr attributes[:ref] if attributes[:ref]
25
+ collection_attr attributes[:collection] if attributes[:collection]
26
26
  end
27
27
  end
28
28
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Yosuke Doi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2013-06-08 00:00:00 +09:00
17
+ date: 2013-06-10 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency